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

Re: TPR1 post-mortem

Thread Previous | Thread Next
Adam Spiers
March 8, 2002 05:49
Re: TPR1 post-mortem
Message ID:
Marcelo E. Magallon ( wrote:
>  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 :-)

"One step" for very unusual bindings of "one" ;-)

I also thought of this.  However you can avoid messing around with
factorials by simply extracting digits from the powers of 11.

I'm just gutted that I had considered *1.1 and then rejected it as
being too much hassle to remove the two outer digits.  If only I'd
realised I could have done that in 3 extra characters!

Ah well.  At least mine was the best entry did the magic op, the pop,
and removal of the trailing digit all within one s///ge.  Small
comfort ...

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