There was this math problem that went viral recently – it was a Singapore Math Olympiad problem meant for 14-year olds which surprisingly many adults couldn’t solve. A friend sent me a link to that problem and I solved it with pen and paper in about 10 minutes, leaving me feeling hardly challenged. I guess really-tough questions aren’t the ones that actually go viral. If anything, a math problem going viral means it caters to an average IQ, something like a 100 – which then left me wondering whatever my IQ was! I had taken many online IQ tests when I was pursuing my engineering degree and my scores ranged between **135** and **145**. But they weren’t tests one could really feel great about, mainly because everyone I knew who took them, scored **110+**. I never took a Mensa test in the past, so I’m not sure whether I’d have made the cut. Anyway, I decided to check Quora to see if the nerds had found anything remotely mimicking a Mensa type IQ test. So I checked out this one and got a **130**. It seems to be the least I’ve ever got on an IQ test, so without giving you any rationale to why I feel this might be closer to accurately measuring your IQ, I say it’s probably worth a shot.

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:

### Like this:

Like Loading...

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

LikeLike

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.

LikeLike

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?

LikeLike

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

LikeLike

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

LikeLike