On Nov 3, 11:45 pm, [EMAIL PROTECTED] wrote: > > Thats interesting code but seems to give a different output, > suggesting thet the underlying algorithm is different. > Ignoring linebreaks and case, the original code gives: > abcd bacd bcad bcda acbd cabd cbad cbda acdb cadb cdab cdba abdc badc > bdac bdca adbc dabc dbac dbca adcb dacb dcab dcba > > The output from the above program, when converted to strings is: > abcd abdc acbd acdb adbc adcb bacd badc bcad bcda bdac bdca cabd cadb > cbad cbda cdab cdba dabc dacb dbac dbca dcab dcba >
Note: items = [''.join(p) for p in perm('abcd') ] assert items == sorted(items) items = list(all_perms('abcd')) assert items != sorted(items) -- http://mail.python.org/mailman/listinfo/python-list