News for hackers. Stuff that matters.
Re:Math puzzle for Vietnamese eight-year-olds by IanCal on Thursday May 21, 2015 @04:08AM (#9581511)
You need to swap the 1 at the end for an 11.

Also, this code for me returns 2672 solutions although I don't believe all are valid due to integer division. Perhaps a python 2 -> python 3 difference? (py2 here)

Re:Math puzzle for Vietnamese eight-year-olds by ust on Thursday May 21, 2015 @08:18AM (#9582158)
I have the same number, do you think there is a reason why they are not all valid? EDIT: actually the number I calculate is 2796. Also using Python 2..
Re:Math puzzle for Vietnamese eight-year-olds by IanCal on Thursday May 21, 2015 @08:41AM (#9582269)
Partly it might be due to needing "-10" at the end rather than -1 (I think I may have corrected it to -11 by mistake).

However, larger is the difference in how division works.

Python2: 3 / 2 => 1

Python3: 3 / 2 => 1.5

Re:Math puzzle for Vietnamese eight-year-olds by ust on Thursday May 21, 2015 @09:37AM (#9582635)
Would forcing the integer result fix this problem? Something like:

    def f(a, b, c, d, e, f, g, h, i):
        return a + int((13 * b * i + g * h * c) / (i * c)) + d + 12 * e - f - 11 - 10
If I try it like this, I still have the same number of solutions... Maybe I'm missing something..

EDIT: code formatting...

Re:Math puzzle for Vietnamese eight-year-olds by IanCal on Thursday May 21, 2015 @09:49AM (#9582707)
No, the problem is the other way around. Keeping them as integers and just using '/' is what's causnig the problem. You can either force them to be floats (not the result, the parameters in the calculation), or you can explicitly look for divisions that have remainders.
Re:Math puzzle for Vietnamese eight-year-olds by acqq on Thursday May 21, 2015 @04:22AM (#9581549)
At the end should be 10.

And with checks to have only divisions without the remainder I get 20 solutions, the first one being (3, 2, 1, 5, 4, 7, 8, 9, 6)?

Re:Math puzzle for Vietnamese eight-year-olds by IanCal on Thursday May 21, 2015 @05:00AM (#9581632)
Yes, I get the same.

Edit - Ah yes, 10, sorry.