Just for fun: Countdown numbers game solver

Terry Jones terry at jon.es
Mon Jan 21 06:54:22 EST 2008


>>>>> "Arnaud" == Arnaud Delobelle <arnodel at googlemail.com> writes:

Arnaud> Sorry I gave an incorrect example to illustrate my question last
Arnaud> night (I blame this on baby-induced sleep deprivation ;), so I'll
Arnaud> have another go:

Arnaud> Say I have 2, 3, 4, 100 and I want to make 406.  AFAICS there is only
Arnaud> one way: (2*3)+(4*100), i.e. in postfix notation:
Arnaud> 2 3 * 4 100 * +

Arnaud> It seemed to me that your function wouldn't generate that sort of
Arnaud> solution (as you always extend partialSolution by [num, op] making
Arnaud> the subsequence [mul, add] impossible).  Am I wrong?

No, you're right.  I actually started out with a stack solution, and then
switched to something simpler (too simple). I'm going to redo it, but maybe
not right now...

Thanks!

Terry



More information about the Python-list mailing list