1 Star 0 Fork 0

sickle12138/game24

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
test.html 1.81 KB
一键复制 编辑 原始数据 按行查看 历史
auntyellow 提交于 2017-04-12 22:43 . bugfix: add pattern 2, 2, 2, a
<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>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sickle12138/game24.git
git@gitee.com:sickle12138/game24.git
sickle12138
game24
game24
master

搜索帮助