https://github.com/brayvid/twenty-four
Solver for the game of 24.
https://github.com/brayvid/twenty-four
game recreational-mathematics
Last synced: 3 months ago
JSON representation
Solver for the game of 24.
- Host: GitHub
- URL: https://github.com/brayvid/twenty-four
- Owner: brayvid
- Created: 2019-05-29T11:36:46.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-05-29T15:44:28.000Z (over 6 years ago)
- Last Synced: 2025-01-11T11:18:28.705Z (about 1 year ago)
- Topics: game, recreational-mathematics
- Language: Python
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# TwentyFour
Solver for a generalized version of the game of 24 - https://en.wikipedia.org/wiki/24_Game
`````
given = [2, 3, 5, 12]
target = 24
twentyfour(given, target)
> ['d $ (c $ (a $ b))', (5, 2, 3, 12), (3, 1, 3), '+, -, *, /']
`````
The function output shows a representation of the solution expression, followed by the order in which the numbers are used, followed by the order in which operations are used ("+" is 0, "-" is 1, etc).
In the above example, the solution can be read off as 12 / (3 - (5 / 2)) = 24.