Subj : Re: how to generate a sequence? To : comp.programming From : gswork Date : Thu Sep 08 2005 07:43 am Neo wrote: > wrote in message > news:1126182754.841342.319360@g44g2000cwa.googlegroups.com... > > > > Neo wrote: > >> Hi All, > >> > >> I have problem, I want to generate all possible (unique) combinations ... > > > > have you checked out any permutation algorithms? source code is easy > > to find online. > > Well, I first thought it will be a simple thing. when I give it a try, > damm.. I was not able to devise an easy method to generate this sequence, > this drives me crazy, anyway then I decided to not do a google and attack > it, after two hrs. I was able to come up with a solution (recursive). and > just for the sake of watching things work, wrote a quick script in PERL. > > Well, for 4-5 symbols it was quick enough, but to ma surprise when I > increase symbols to 9 damm.... it took 01 min 28.0954414 sec to exec and > it process's mem usage was 216 MB !!!!!!!!!!!!!!!!!!!!! that'll be the recursion. A non recursive permutation algorithm would help you for the constrained environment you mention (the 32kb one) it would involve swapping elements in the set in an iterative process but exactly how got me thinking - so I looked around - indeed there was a website all about it! (http://www.geocities.com/permute_it/) hope it helps you. .