Monthly Archives: March 2013

Quora answers “Brilliant” problem

Came across this question on Quora (Quora is an infinite time sink BTW!) The original question is at

Wonder why people post puzzle-type questions on Quora!

Anyway, the highest ranked answer gives a nice way to approach the problem. I would not be able to think that way and just used the brute-force:
Here is the ruby code to solve it:

def testit(a)
  (x,y,z)= a/100%10,a/10%10,a%10
  return a == x*x+y*y+z*z + 543

q=(111..999).select{|q| testit(q)}

The answer is 2626, the last 3 digits being 626.