# another viral math puzzle

**Xi'an's Og » R**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

After the Singapore Maths Olympiad birthday problem that went viral, here is a Vietnamese primary school puzzle that made the frontline in The Guardian. The question is: *Fill the empty slots with all integers from 1 to 9 for the equality to hold*. In other words, find *a,b,c,d,e,f,g,h,i* such that

*a*+13x*b*:*c*+*d*+12x*e*–*f*-11+*g*x*h*:*i*-10=66.

With presumably the operation ordering corresponding to

*a*+(13x*b*:*c)*+*d*+(12x*e)*–*f*-11+(*g*x*h*:*i)*-10=66

although this is not specified in the question. Which amounts to

*a*+(13x*b*:*c)*+*d*+(12x*e)*–*f*+(*g*x*h*:*i)*=87

and implies that *c* divides *b* and *i* divides *g*x*h*. Rather than pursing this analytical quest further, I resorted to R coding, checking by brute force whether or not a given sequence was working.

baoloc=function(ord=sample(1:9)){ if (ord[1]+(13*ord[2]/ord[3])+ord[4]+ 12*ord[5]-ord[6]-11+(ord[7]*ord[8]/ ord[9])-10==66) return(ord)}

I then applied this function to all permutations of {1,…,9}* [with the help of the perm(combinat) R function]* and found the 128 distinct solutions. Including some for which b:c is not an integer. (Not of this obviously gives a hint as to how a 8-year old could solve the puzzle.)

Filed under: Books, Kids, R, University life Tagged: mathematical puzzle, permutation, primary school, The Guardian, Vietnam

**leave a comment**for the author, please follow the link and comment on their blog:

**Xi'an's Og » R**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.