# Solution to [Viral] Math Puzzle for Vietnamese Eight-Year-Olds (Using R) A week back, there was yet another math puzzle that had gone viral, meant for Vietnamese eight-year-olds, a problem that had stumped parents and teachers. You need to fill in the empty boxes below with the digits from 1 to 9 so that the equation makes sense, following the order of operations – multiply first, then division, addition and subtraction last. Apparently, this problem was for third graders in the town of Bao Loc in the Vietnamese Highlands. I didn’t solve this one with pen and paper, and instead wrote an R program. It’s clearly a problem with a fixed number of variables (nine) associated with standard math operators, meaning there would be 9! (362880) permutations – which makes you think there’s got to be more than one solution. It became obvious I had to write some code.

I wrote a function appropriately named baoloc() to list out the solutions to this problem. The code is self explanatory. I got 128 unique solutions, which means if the students had to solve this problem with pencil on paper, they could get one of 128 possible answers, which makes the job of the examiner arduous and boring!

The above code produces the following solutions:

## 5 thoughts on “Solution to [Viral] Math Puzzle for Vietnamese Eight-Year-Olds (Using R)”

1. John Ross says:

Crap. all wrong! did you check ANY? show a result using any of your formulae!

Like

• Anirudh says:

If you use BODMAS or PDMAS as it is sometimes called, you’ll notice that ALL the 128 solutions work out to the answer 66.

Like

2. John Ross says:

7+13=20×2=40:8=5+9=14+12=26×6=156-5=151-11=140+1=141×3=423:4=105.75-10=95.75 ! NOT 66!

please show how you think this works?

Like

• Anirudh says:

Here you go:

7 + {(13 x 2) / 8 } + 9 + (12 x 6) – 5 – 11 + {(1 x 3) / 4) -10 = 66

I hope the above satisfies you. If you are wondering why I had to solve it this way, refer to this link:
https://en.wikipedia.org/wiki/Order_of_operations

Like

3. Kevin Nguyen Vo says:

How long does it take to let the program generate 128 solutions? Since listing all permutation create a very large dataset:
permutations <- permn(numbers) ## list of all permutations of vector input

Like