The stupid question is the question not asked | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Hello dear monks,
I'm trying to create a function that by getting a number of Ones and Zeroes (if possible also the number of the generation) shall give eventually give all the conbinations without repeats, because Algorithm::Combinatorics can't differ 2 zeroes( for it 010 and 010 is different, but for me it's the same).
I've come with an idea of printing them chronologically like (if $ones=2 and $zeroes=3): 00011 00101 01001 10001 00110 01010 10010 01100 10100 11000 where these 10 are all variations without repeats. i tried achieving my goal in 2 ways : 1. trying to simply print then like that - but this gave out 00011 00110 01100 11000 00101 01001 10001 and afterwars there were strange thigs like 000110000, etc; also it didn't print 00110,01010,...,01100,etc. 2. printing them by distanses from zero to one using a flipFlop flag (after a set of ones there must com a set of zeroes and the opposite) - but this gave out 11000 1001 11000 1000 1100 10100 11000 1001 and many other strange reasults. I searched Google and Google-Code-search and the only similar things i found were connected to colors and cropping the results that repeated (but still all the results( 24! ) were checked). Is there a simple logical way to print it out( using map() or/and join()) or fixing one of the codes i tried ? In reply to One Zero variants_without_repetition by thenetfreaker
|
|