in reply to Derangements iterator
Producing a single derangement (such as might be needed for a Secret Santa list) is just a matter of doing a rotation. Of course, you'd want to randomize the order first, to keep things secret:
Caution: Contents may have been coded under pressure.
use List::Util 'shuffle'; my @from = shuffle(@ARGV); print "$from[$_-1] => $from[$_]\n" for 0..$#from;
Caution: Contents may have been coded under pressure.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Derangements iterator
by jdporter (Paladin) on Dec 29, 2005 at 19:09 UTC | |
by Roy Johnson (Monsignor) on Dec 29, 2005 at 19:14 UTC | |
by Anonymous Monk on Dec 31, 2005 at 12:29 UTC | |
by Jedaļ (Initiate) on Dec 31, 2005 at 13:34 UTC |
In Section
Cool Uses for Perl