Re: One-Liners Mashup (#177 again)
- From: Ken Bloom <kbloom@xxxxxxxxx>
- Date: Mon, 29 Sep 2008 14:30:18 -0500
Matthew Moss <matthew.moss@xxxxxxxxx> wrote:
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
Chanoch (Ken) Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
- Prev by Date: Re: ruby1.9 block scope
- Next by Date: Re: my ears are burning... ;)
- Previous by thread: Re: One-Liners Mashup (#177 again)
- Next by thread: Re: [QUIZ] One-Liners Mashup (#177 again)