Talk:24 game/Solve

From Rosetta Code

Python Solution incomplete?

One problem with this solution is that it can only attempt one set of brackets. What if more than one set of brackets is necessary? --164.67.235.128 17:19, 1 November 2009 (UTC)

I had thought of that, but that was after I had a solution for none or any one set of brackets, which I thought was crucial. I couldn't at the time, come up with a set of numbers where the solution needed two brackets, (I didn't try very hard - I was enjoying what I had wrote already); so just left it out. Do you know of a set of numbers that can only be solved with the use of two sets of brackets? --Paddy3118 18:57, 1 November 2009 (UTC)
P.S. Gosh you're sharp. No flies on you :-)
My son just worked out the following result: (9-5)*(9-3), but putting 9,5,9,3 into the solver made it produce: 5 / 3 * 9 + 9. I don't know if a less than two bracket solution exists for every two bracket solution though? --Paddy3118 21:40, 1 November 2009 (UTC)
Paddy, Python supports declarative logic, doesn't it? Just thought I'd mention it. (It'd be nice to see some more declarative logic solutions and/or tasks, too.) --Michael Mol 00:23, 2 November 2009 (UTC)
Unfortunately declarative logic is only supported by external libraries in Python. --Paddy3118 06:42, 2 November 2009 (UTC)
If external libraries are un-Pythonic, I suppose solutions involving antigravity are out of the question... --Michael Mol 11:16, 2 November 2009 (UTC)
I think it's perfectly OK to invoke external libraries – you'd have to do that in many other languages anyway – but if that's done, they should be properly declared with the right {{template}} so that it's easy to see what's going on. (Internal libs, by which I mean ones that are included with standard distributions of the language, don't need such extra declarations.) —Donal Fellows 11:35, 2 November 2009 (UTC)

Should we enumerate all solutions?

It turns out to take almost no time at all to enumerate all the possible solutions, as there's only 7680 (5 fundamental parse structures, 24 mappings of digits to the leaves, and 64 mappings of operators to the branches). Hence, is it acceptable to produce all the solutions? Or only the first one found? –Donal Fellows 13:53, 2 November 2009 (UTC)