Just for fun: Countdown numbers game solver

Terry Jones terry at jon.es
Mon Jan 21 05:29:02 EST 2008


>>>>> "dg" == dg google groups <dg.google.groups at thesamovar.net> writes:

dg> It's great how many different sorts of solutions (or almost solutions)
dg> this puzzle has generated. Speedwise, for reference my solution posted
dg> above takes about 40 seconds on my 1.8GHz laptop, and the less elegant
dg> version (on my webpage linked to in the original post) takes about 15
dg> seconds. It seems to me like surely this problem can be more
dg> efficiently solved than that?

dg> Paul: 758 = 8+(5*((2+4)*25))

For this I get:

2 solutions to: target 758, numbers = (2, 4, 5, 8, 25)
        (4, 2, 'add', 25, 'mul', 5, 'mul', 8, 'add')
        (25, 4, 'mul', 5, 'sub', 8, 'mul', 2, 'sub')

real    0m0.118s
user    0m0.074s
sys     0m0.044s


Terry



More information about the Python-list mailing list