RosettaCodeData/Task/24-game/R/24-game-2.r
2013-04-10 14:23:37 -07:00

29 lines
555 B
R

> twenty.four()
Make 24 out of the numbers 1, 6, 7, 5 and the operators +, -, *, /, ( .
Enter 'q' to quit, '!' to select new digits, or '?' to repeat this message.
> 6*(5-1)
Must use each number once.
> 1 + 6*5 - 7
Correct!
New digits: 7, 2, 9, 3
> (7+9)/2*3
Correct!
New digits: 1, 4, 1, 7
> 4*(7-1)
Must use each number once.
> (7-1)*4*1
Correct!
New digits: 1, 5, 2, 8
> (5-1)^2+8
'^' not allowed.
> !
New digits: 2, 8, 5, 2
> 52-28
'52, 28' not allowed.
> (8-2)*(5-2/2)
Must use each number once.
> (8+2)*2+5
Evaluated to 25 ( goal 24 )
> q
Goodbye!