On 5/11/05, John Tsangaris <[EMAIL PROTECTED]> wrote:
> I was asked to provide the 73 occurrence of a sequence of numbers, with
> the numbers 12345. Each number can be used only once, and there are a
> possible 120 combinations.
>
> I was called by a client to figure this out for them, since one of their
> 2nd grade children was required to provide the answer to this question. I
> only had a coule of minutes so I pulled this code out of my sleeve to get
> the answer. But, I'm curious to find out if there is a sleeker way to get
> the answer and full sequence (preferably more advanced than my 2nd grade
> answer).
Do I smell golf?
perl -le 'map/(.).*\1/||print,glob"{1,2,3,4,5}"x5'
This works on Unix. On Windows you'll have to switch quotes around.
Cheers,
Ben
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm