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:
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/
.
- References:
- [QUIZ] One-Liners Mashup (#177 again)
- From: Matthew Moss
- Re: [QUIZ] One-Liners Mashup (#177 again)
- From: Bill Kelly
- Re: [QUIZ] One-Liners Mashup (#177 again)
- From: James Gray
- Re: [QUIZ] One-Liners Mashup (#177 again)
- From: Ken Bloom
- Re: One-Liners Mashup (#177 again)
- From: Matthew Moss
- [QUIZ] One-Liners Mashup (#177 again)
- 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)
- Index(es):
Relevant Pages
|