This smells like homework, but *shrug*

On Wed, 2005-05-11 at 14:59, John Tsangaris wrote:
> I was asked to provide the 73 occurrence of a sequence of numbers,
> withthe numbers 12345.  Each number can be used only once, and there
> are apossible 120 combinations.
> I was called by a client to figure this out for them, since one of
> their2nd grade children was required to provide the answer to this
> question.  Ionly had a coule of minutes so I pulled this code out of
> my sleeve to getthe answer.  But, I'm curious to find out if there is
> a sleeker way to getthe answer and full sequence (preferably more
> advanced than my 2nd gradeanswer).

perl -le '$n=0;sub x{my($s,@l)[EMAIL PROTECTED];if (@l){for my 
$l(@l){x($s.$l,grep{$_ ne [EMAIL PROTECTED])}}else{print ++$n," 
",$s}}x("",1,2,3,4,5)'

Easy permutation problem.

-- 
Aaron Sherman <[EMAIL PROTECTED]>
Senior Systems Engineer and Toolsmith
"It's the sound of a satellite saying, 'get me down!'" -Shriekback


 
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to