Julia code to solve Twenty Four puzzles
Author scheinerman
1 Star
Updated Last
2 Years Ago
Started In
October 2016


Build Status

Twenty Four is a number game. The player is presented with a card containing four numbers. The object is to use those four numbers to make the value 24 using the four standard arithmetic operations (plus, minus, times, divide). This Julia module provide solves these puzzles.


Use the solve function to find solutions to Twenty Four puzzles. Simply provide two or more values (either integers or rationals).

julia> solve(3,4,5,8)

julia> solve(5,5,5,1)

julia> solve(5,5,5,2)
"No solution"

julia> solve(1//2, 1//3, 7, 3)

To do list

  • Permit alternative goals besides 24.
  • Our code might give a solution in which some of the intermediate values are negative. One can prove this can always be avoided (assuming the given numbers are all positive). Modify the code so all intermediate values are nonnegative.

Required Packages

Used By Packages

No packages found.