On Jan 21, 11:29 am, Terry Jones <[EMAIL PROTECTED]> wrote:
> >>>>> "dg" == dg google groups <[EMAIL PROTECTED]> 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

Terry, your technique is efficient and pretty readable! All that could
be added now is a way to output the data in a more user-friendly
print. (it currently reminds me of Lisp operands done backwards :) )

Also perhaps the creation of a random generator for the 6 numbers and
the target :)

I do not remember if countdown enforced that it must be possible to
actually get the target, you could also get close to it. (I believe
you would get different points depending on this)

Will have to read up on how many large numbers you can have, as well
as small. Currently I think it is you can take up to 4 large numbers,
and up to 6 small numbers to a total of 6. (you must always have 6
numbers to work with)
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to