Go number cruncher

August 17, 2010

programming

Write a number cruncher that works as follows:

  • Pick six (6) random numbers from this list:
    1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 25, 50, 75, 100
    

Numbers may be picked multiple times.

  • Pick one (1) random number (i) in the range:

    1 … 1000
    

  • Tell how, by combining the first 6 numbers or or subset with the operators +,-,* and /, you can make i;

An example. We have picked the numbers: 1, 6, 7, 8, 8 and 75. And i is 977. This can be done in many different ways, two ways are:

((((1 * 6) * 8) + 75) * 8) - 7 = 977
(8*(75+(8*6)))-(7/1) = 977

Another:

(((6*8)+75)*8)-7 = 977

When using only a subset. This one is without the number 1.

Credit for this particular exercise goes to JC van Winkel.

Golang