From: Karsten Meier Date: 2004-07-19T02:47:11+09:00 Subject: Re: Another little algoritmic help needed... There is a solution in the pleac cookbook, I have transferred it from the perl cookbook. See http://pleac.sourceforge.net/pleac_ruby/arrays.html Search for "program permute" The second solution enables you to get the n-th permutation, so you can just increment a integer each time you call the method, and you don't need to store any arrays. Regards Karsten Meier Meino Christian Cramer wrote: > Hi, > > > I want to produce from a give string all permutations of its > characters. > > Building all permutations of something is a typical recursive task. > But in this case I dont want a recursive solution because: > > > > 1.) Each call of the according method should return only one > permutation of all possible permutations. > > > and > > > 2.) Since the count of permutation rapidly grows with the count of > characters to permute I dont want to calculate all permutations > first and store them in a big BIG array. > Each new call that method should calculate just that next new > permutation. > > > > I must confess: I have thought about that and did not find any > solution. Even the Sedgwick only offers a recursive solution. > > > Any ideas ? > > Ruby.use! > Meino > >