develooper Front page | perl.fwp | Postings from March 2002

Re: TPR1 post-mortem

Thread Previous | Thread Next
Marcelo E. Magallon
March 8, 2002 00:34
Re: TPR1 post-mortem
Message ID:
Hats off to Ton and Lars!

>> Ton Hospel <> writes:

 > -l $_=pop;s;.;print,s,,$&*1.11%10if/\G../,eg;eg

 Wow.  My last fumblings where something along the lines of:

 -l $_=pop;0while+print,s+.+$&*111%100if/../+eg,chop

 which I couldn't get to work.

 Perhaps as post-mortem regarding that discussion about the tiebreaker,
 I was wondering how you guys got rid of the while.  I guessed there
 wasn't a while involved because I thought "there's got to be a pop, a
 print, certainly an s with e and g".  If figured the best solution
 didn't had a while in it since in mine that uses 7 strokes with 6 \w's.
 The above solution also uses 7 strokes for the "same" purpose
 (side-effects aside, which is the killer), but the tie-breaker is

 The 1.11%10 bit made me giggle for some reason.

 Regarding my "one step" solution, the secret can be computed as:

    Op(i=1..digits, C(i, digits)*digit[i])

 where Op(a,b) := (0, 1..9, 1..9, ...)[a+b] and C(i, j) := j!/i!/(j-i)!
 (or something like that, I can't think straight right now).  This lead
 to a horribly long solution that doesn't even pass the test program :-)

 Thanks guys, my first tournament ever was lots of fun!


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About