-
Notifications
You must be signed in to change notification settings - Fork 32
/
tot_game_24.gen
74 lines (66 loc) · 1.45 KB
/
tot_game_24.gen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# root
## use: evaluate
Use 4 numbers and basic arithmetic operations: sum, sub, mul, div to obtain 24 in 1 equation.
Example:
Input: 2 8 8 14
Possible next steps:
1. 2 + 8 = 10 (left: 8 10 14)
2. 8 / 2 = 4 (left: 4 8 14)
3. 14 + 2 = 16 (left: 8 8 16)
4. 2 * 8 = 16 (left: 8 14 16)
5. 8 - 2 = 6 (left: 6 8 14)
6. 14 - 8 = 6 (left: 2 6 8)
7. 14 / 2 = 7 (left: 7 8 8)
8. 14 - 2 = 12 (left: 8 8 12)
Input: 4 5 8 2
Generate 8 possible next steps.
Then call evaluate with each possible step.
Output final equation.
All given numbers from the input must be used in the final expression, e.g.
7 * (3 + 1) − 2 = 24
6 * 5 - 8 + 2 = 24
8 * 2 + 9 - 1 = 24
etc.
# evaluate
## input: numbers to evaluate e.g. 2 5 7
## keep_context: false
Evaluate if given numbers can reach 24 (sure/likely/impossible).
All given numbers must be used in each expression.
Example:
10 14
10 + 14 = 24
sure
11 12
11 + 12 = 23
12 - 11 = 1
11 * 12 = 132
11 / 12 = 0.91
impossible
4 4 10
4 + 4 + 10 = 8 + 10 = 18
4 * 10 - 4 = 40 - 4 = 36
(10 - 4) * 4 = 6 * 4 = 24
sure
4 9 11
9 + 11 + 4 = 20 + 4 = 24
sure
5 7 8
5 + 7 + 8 = 12 + 8 = 20
(8 - 5) * 7 = 3 * 7 = 21
I cannot obtain 24 now, but numbers are within a reasonable range
likely
5 6 6
5 + 6 + 6 = 17
(6 - 5) * 6 = 1 * 6 = 6
I cannot obtain 24 now, but numbers are within a reasonable range
likely
10 10 11
10 + 10 + 11 = 31
(11 - 10) * 10 = 10
10 10 10 are all too big
impossible
1 3 3
1 * 3 * 3 = 9
(1 + 3) * 3 = 12
1 3 3 are all too small
impossible