## Three Wise Men

### December 28, 2012

It is easier to convert all the prices to pennies and work with a multiplicative total of 65.52 * 100^{3}. Here’s a function using a list comprehension that solves the problem for any given total:

`(define (magi n)`

(list-of (list a b c)

(a range 1 (quotient n 2))

(b range (+ a 1) (quotient (- n a) 3))

(c is (- n a b))

(= (* a b c) (* n 10000))))

`> (magi 6552)`

((52 200 6300))

The three prices are $0.52, $2.00 and $63.00. You can run the program at http://programmingpraxis.codepad.org/VpH8ZI25.

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 (https://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: […]