Just for fun: Countdown numbers game solver

Terry Jones terry at jon.es
Mon Jan 21 04:39:44 CET 2008


My output looks better sorted. I.e., for s in sorted(solutions)...

Giving the easier to read/compare:

Target 234, numbers = (100, 9, 7, 6, 3, 1)
        (6, 1, 'add', 100, 'mul', 7, 'sub', 9, 'add', 3, 'div')
        (6, 9, 'sub', 7, 'mul', 1, 'sub', 100, 'add', 3, 'mul')
        (7, 3, 'mul', 6, 'sub', 9, 'mul', 1, 'sub', 100, 'add')
        (7, 6, 'mul', 3, 'mul', 1, 'sub', 100, 'add', 9, 'add')
        (7, 6, 'mul', 3, 'mul', 100, 'sub', 9, 'mul', 1, 'mul')
        (100, 1, 'sub', 3, 'div', 7, 'mul', 6, 'sub', 9, 'add')
        (100, 1, 'sub', 7, 'mul', 9, 'sub', 3, 'div', 6, 'add')
        (100, 7, 'mul', 3, 'mul', 6, 'add', 9, 'div', 1, 'mul') *
        (100, 7, 'mul', 6, 'sub', 1, 'sub', 9, 'add', 3, 'div')
        (100, 7, 'sub', 3, 'div', 1, 'sub', 9, 'add', 6, 'mul')
        (100, 7, 'sub', 3, 'div', 6, 'sub', 1, 'add', 9, 'mul')
        (100, 9, 'add', 7, 'add', 1, 'add', 3, 'div', 6, 'mul')
        (100, 9, 'sub', 7, 'div', 6, 'mul', 3, 'mul', 1, 'mul')
        (100, 9, 'sub', 7, 'sub', 6, 'sub', 3, 'mul', 1, 'mul')

Terry



More information about the Python-list mailing list