code challenge: generate minimal expressions using only digits 1, 2, 3

Paul Rubin http
Fri Feb 20 11:02:45 EST 2009


Trip Technician <luke.dunn at gmail.com> writes:
> I have a dim intuition that it could be done with a very clever bit of
> recursion, but the exact form so far eludes me.

This sounds a little like a homework assignment, or maybe a challenge
you are trying to solve for yourself, rather than be given a complete
answer for.  Anyway, the basic idea is to enumerate the expression
trees with 1 digit, then 2 digits, then 3 digits, etc, and compute the
value expressed by each tree.



More information about the Python-list mailing list