Hi all
My son sometimes plays this little maths game, and now wants to write a program to do it.
Looking at it I can see there's a number of methods of attack, and thought some of you guys would like to try to come up with an elegant solution.
Here's the game:
You take a dice and roll it 3 (or maybe 4) times and see how many results you can come up with using some or all of those numbers and the standard +,-, * and / operators. You usually start looking for the result 1 and work up.
E.g. if you roll 2,3,5 you can get
1 = 3-2 or (5/(3-2)) if you want to look for other ways
2 = 2
3 = 3
4 = 5-(3-2)
5 = 5
6 = 2*3 or 5+3-2
7 = 5+2
etc etc
Enjoy.
Cheers,
T.
My son sometimes plays this little maths game, and now wants to write a program to do it.
Looking at it I can see there's a number of methods of attack, and thought some of you guys would like to try to come up with an elegant solution.
Here's the game:
You take a dice and roll it 3 (or maybe 4) times and see how many results you can come up with using some or all of those numbers and the standard +,-, * and / operators. You usually start looking for the result 1 and work up.
E.g. if you roll 2,3,5 you can get
1 = 3-2 or (5/(3-2)) if you want to look for other ways
2 = 2
3 = 3
4 = 5-(3-2)
5 = 5
6 = 2*3 or 5+3-2
7 = 5+2
etc etc
Enjoy.
Cheers,
T.
Comment