Just for fun: Countdown numbers game solver
Terry Jones
terry at jon.es
Mon Jan 21 04:16:14 EST 2008
>>>>> "Paul" == Paul Rubin <"http://phr.cx"@NOSPAM.invalid> writes:
Hi Paul
Paul> Here's my latest, which I think is exhaustive, but it is very slow.
Paul> It prints a progress message now and then just to give the user some
Paul> sign of life. It should print a total of 256-8 = 248 of those
Paul> messages and it takes around 20 minutes on my old 1 Ghz Pentium 3.
Paul> It does find plenty of solutions for 234, e.g.
Paul> 234 mul(9,sub(mul(mul(6,mul(3,1)),7),100))
Paul> There are some obvious clunky ways to speed it up through memoizing
Paul> and symmetry folding but I can't help thinking there's a concise
Paul> elegant way to do that too.
The symmetry folding is important, you can cut off many recursive calls. My
code runs in 0.5 seconds for the 234 problem, but I have a MacBook Pro :-)
Terry
More information about the Python-list
mailing list