From: Ken Bloom Date: 2008-09-30T04:39:08+09:00 Subject: Re: One-Liners Mashup (#177 again) Matthew Moss wrote: > >> New challange: >> >> Starting with an array, find the first permutation of the elements of >> that array that is lexicographically greater than (i.e. sorts after) >> the given array. > > I was tempted to port the C++ next_permutation code, but then I > realized I have class. :( I've done it, and posted it here, but It's not one line. I'm not sure if that's even doable. What I do know is that most permutation generators in Ruby just look at positions, not data, and by doing so, they yield identical permutations in a single iteration when there are indentical data elements. --Ken -- Chanoch (Ken) Bloom. PhD candidate. Linguistic Cognition Laboratory. Department of Computer Science. Illinois Institute of Technology. http://www.iit.edu/~kbloom1/