-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest.html
More file actions
74 lines (71 loc) · 1.81 KB
/
Copy pathtest.html
File metadata and controls
74 lines (71 loc) · 1.81 KB
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
<script type="text/javascript" src="24-expressions.js"></script>
<script type="text/javascript" src="24.js"></script>
<span id="output"></span>
<script type="text/javascript"><!--
function test(na, nb, nc, nd, expected) {
var ns = [na, nb, nc, nd];
var solutions = solve(ns);
var s = ns + " should have " + expected +
" solution(s), actually " + solutions.length + " solution(s)<br>";
for (var i = 0; i < solutions.length; i ++) {
s += render(solutions[i]) + " = 24<br>";
}
output.innerHTML += s;
}
var t = new Date().getTime();
// n0 = n1 = n2 = n3
test(3, 3, 3, 3, 1);
// n0 = n1 = n2 < n3
test(1, 1, 1, 12, 1);
test(2, 2, 2, 8, 3);
test(3, 3, 3, 5, 1);
test(3, 3, 3, 4, 2);
// n0 = n1 < n2 = n3
test(1, 1, 5, 5, 1);
test(2, 2, 3, 3, 2);
test(3, 3, 5, 5, 1);
test(4, 4, 5, 5, 3);
// n0 = n1 < n2 < n3
test(1, 1, 4, 5, 2);
test(2, 2, 4, 5, 4);
test(2, 2, 3, 12, 6);
test(3, 3, 5, 6, 7);
test(3, 3, 4, 8, 3);
// n0 < n1 = n2 = n3
test(1, 8, 8, 8, 1);
test(2, 3, 3, 3, 2);
// n0 < n1 = n2 < n3
test(1, 2, 2, 6, 2);
test(1, 3, 3, 4, 3);
test(2, 6, 6, 8, 5);
test(2, 3, 3, 8, 3);
test(2, 12, 12, 13, 2);
test(2, 3, 3, 4, 0);
test(3, 6, 6, 9, 4);
test(3, 4, 4, 6, 5);
test(4, 6, 6, 7, 2);
test(5, 6, 6, 7, 4);
// n0 < n1 < n2 = n3
test(1, 3, 6, 6, 3);
test(1, 2, 12, 12, 2);
test(2, 4, 6, 6, 5);
test(2, 3, 12, 12, 4);
test(2, 11, 12, 12, 2);
test(2, 3, 4, 4, 3);
test(4, 6, 8, 8, 4);
test(3, 4, 12, 12, 2);
test(3, 7, 8, 8, 3);
test(11, 12, 13, 13, 2);
// n0 < n1 < n2 < n3
test(1, 4, 6, 8, 3);
test(1, 2, 3, 8, 4);
test(2, 4, 6, 12, 10);
test(3, 4, 11, 13, 4);
test(3, 5, 6, 8, 3);
test(4, 6, 9, 10, 4);
test(3, 4, 5, 8, 6);
test(3, 8, 9, 10, 3);
test(2, 3, 7, 8, 4);
test(5, 6, 7, 8, 3);
output.innerHTML += (new Date().getTime() - t) + "ms";
--></script>