## Three Wise Men

### December 28, 2012

We have a simple Christmas puzzle today:

Three wise men named Caspar, Melchior and Balthazar went to Macy’s Department Store on 34th Street to buy gifts of gold, frankincense, and myrrh. When they took their gifts to the cashier, she multiplied the prices of the items and found a total price of $65.52, but the wise men noticed that she multiplied the numbers and asked her to compute the total price again, but this time using addition instead of multiplication. When she did, the cashier found that the total was exactly the same. What were the individual prices of the three gifts?

Your task is to solve the puzzle and find the three prices. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

Pages: 1 2

A Python version.

[…] today’s Programming Praxis exercise, our goal is to solve a puzzle in which both the addition and […]

My Haskell solution (see http://bonsaicode.wordpress.com/2012/12/28/programming-praxis-three-wise-men/ for a version with comments):

[…] Pages: 1 2 […]

Takes a few minutes:

This is an easier version of an earlier problem (http://programmingpraxis.com/2009/11/27/7-11/). Unlike the other problem, it seems that you can just brute force this one and still have it run fairly quickly.

Another Python solution:

[…] Question is from here: […]

My java solution here

My fastest Ruby solution:

$ time ruby wisemen.rb

[0.52, 2.0, 63.0]

real 0m1.919s

user 0m1.795s

sys 0m0.120s

[…] The task: […]