in reply to Permutations in binary

I'd try to Permute (0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1). Then sort (no need to supply a sort routine), and unique the resulting list. Be careful though not to use a hash (collision city!) to do the uniqeing, rather simply tracking and comparing against the previous value.

UPDATE: And I'd have made the problem worse. That turns it into a factorial or 18! which is 6_402_373_705_728_000 permutations. (Even with the most efficient means I can think of to store this, pack it and push the result onto an array, it'd be 14,000 terabytes, not counting the internal overhead for the data structure. *sigh*). This comes about (and is why a uniq and sort would be necessary) because we have elements which are indistinguishable from one another. In the 425756 permutations I generated I had 420376 duplicates, or only 5380 results.

--
perl -pe "s/\b;([st])/'\1/mg"