🧩 24 Game Puzzle Generator
24-point puzzle generator: produces the requested number of arithmetic puzzles solvable to 24 using addition, subtraction, multiplication and division.
📐 工作原理与说明
求解:从数组中任取两个不同元素 a、b,用 + − × 及(|b| > 1e-6 时的 ÷)合成新元素,与剩余元素递归;单元素时 |v − 24| < 1e-6 判命中并回传表达式串。出题:从 1-10 随机取 4 个数,最多试 2000 次直到有解,兜底 [3,3,8,8] 解 (8/(3−8/3))
本工具用于数字谜题生成(24点游戏)的实时计算,依据对应公式与标准运算规则处理,结果按精度实时输出;纯前端运行,数据不上传。
📚 深度解析:24 点游戏出题(四数凑 24)
💡 常见使用场景
- 脑力游戏出题:随机发 4 张 1~13 的牌,保证存在 +−×÷ 凑 24 的解
- 教学训练:练习四则运算与括号组合
- 亲子/课堂:可设定难度与是否含分数
方法
用法:工具自动生成 4 个 1~13 的整数,且至少存在一种四则运算(可加括号)得 24;玩家找出表达式。
算例
例:发牌 [3,3,8,8] → 8/(3−8/3)=8/(1/3)=24。发牌 [1,5,5,5] → 5×(5−1/5)=5×4.8=24。每局解不唯一,可多人比速度。
❓ 常见问题(FAQ)
- 一定会有解吗?
- 出题保证有解(生成时回溯验证);若出现无解组合会被排除重发。
- 能用分数中间结果?
- 标准 24 点允许运算中出现分数(如 8/3),只要最终为 24;部分变体限制整数中间值。
Formula & Standard References
| Item | Formula / Note | Source / Standard |
|---|---|---|
| Operator space | four numbers, three operators and brackets give a few thousand cases | Combinatorial enumeration |
| Solvability precheck | verify solvability by enumeration before presenting a puzzle | Combinatorial enumeration |
| Difficulty tiers | grade by solution count and whether fractional steps are needed | Puzzle design practice |
⚠️ 使用说明与注意事项
- 本工具纯前端运行,数据不会上传到服务器
- 建议在主流浏览器(Chrome/Safari/Firefox/Edge)中使用
- 计算结果仅供参考,请以实际应用场景为准