News for hackers. Stuff that matters.
Re:Math puzzle for Vietnamese eight-year-olds by tzs on Thursday May 21, 2015 @06:53AM (#9581878)
That script (with the -1 at the end replaced with the correct -10) does not work, at least on Python2. It misses the solution (1, 8, 3, 7, 4, 5, 2, 6, 9).

Here's a fixed script:

    from itertools import permutations

    def f(a, b, c, d, e, f, g, h, i):
        return a + (13 * b * i + g * h * c) / (i * c) + d + 12 * e - f - 11 - 10

    solutions = [p for p in permutations(range(1, 10)) if f(*p) == 66]

    print(len(solutions))

There are no comments on this comment yet.