This solves numbers games according to the rules of the TV show Countdown.
Enter a selection of numbers separated by spaces, and an optional target, in the boxes above. Then press enter or click Go.
The selection is conventionally six numbers, but you can enter between two and eight. All the numbers in the selection and target (if given) must be positive integers.
If you enter a target, you'll see all the non-trivially different solutions for that target, and the solution counts for nearby targets.
If you don't enter a target, you'll see a map of all the targets (101-999) at once, colour coded by solveability with the given selection. Click on any target to see the solutions for it.
If you're using a mobile device, you might find this interface easier to use, but it doesn't have all the same features.
The following shortcuts may be included in the selection box to modify the behaviour of the solver.
|4L||Equivalent to 100 75 50 25. For example, 4L 6 3 expands to 100 75 50 25 6 3.|
|fast||Use the fast solver (see below) even if there are fewer than 8 numbers in the selection.|
|cut||Use the fast solver and only show solutions for the specific target, not other targets. This is the default if there are more than 7 numbers in the selection. This improves speed and memory consumption even more than fast.|
|all||Force the solver to show solutions for all targets even if 8 numbers are given. This still uses the fast solver, so only one solution will be given per possible target.|
|@target||Use target as the target. Useful if you don't want the hassle of moving all the way over to the other box to type the target.|
|min=x||A solution must use at least x of the numbers in the selection to be valid. By default there is no minimum. This option is not compatible with the fast option.|
|max=x||A valid solution may not use more than x of the numbers in the selection. By default there is no maximum.|
|Ln||Any number preceded with L is "locked", which means a solution must use it to be valid. Any or all of the numbers in the selection may be locked. This is not compatible with the fast option.|
This solver generates all legal expressions that can be made from the starting numbers, subject to some optimisations. It keeps the expressions that reach the target, or if it's not possible to reach the target, the expressions that get the closest to it.
The solver should solve every puzzle perfectly. If you find a solution to a puzzle which the solver claims is impossible, or you find a closer solution than the closest one it finds, then that's a bug.
The rules are as used by the numbers round on Countdown. The object of the game is to use the starting numbers and any combination of addition, subtraction, multiplication or division to reach the target number or as close as possible to it.
You don't have to use all the numbers, but each number may be used only once. Only positive integers may be used at any stage of the calculation. Negative numbers, powers and fractions are not allowed.
If you enter seven or fewer numbers in the selection, the solver will give you all the non-trivially different solutions for a given target. The solver considers two expressions to be equivalent, and therefore not different solutions, if both expressions do the same operations on the same numbers when their operations are rearranged into a standard order. This means you don't get all the trivial rearrangements of the same solution.
If you enter eight numbers in the selection, we use the "fast" solver to save time and memory. This agressively eliminates duplicate expressions by considering two expressions to be equivalent if they reach the same target with the same starting numbers. We also only show the results for the requested target rather than all the nearby targets, which further improves speed and memory usage.
To find solutions for all targets with eight numbers, use the all keyword. This will take longer and may show significant memory consumption. It still uses the fast solver, which gives you a maximum of one solution for each target and cannot tell you if this is the only solution or what other solutions may exist.
Provided there is no minimum number of numbers to use (min=x) and there are no locked numbers, trivially redundant operations which are never useful in the game are always ignored and not included in the expression. This includes introducing more operations to an expression after it has reached the target, multiplying or dividing by 1, or any part of an expression being equivalent to 2x − x or x² / x.
This solver was written by Graeme Cole and is released under a Creative Commons Attribution Licence. The source code is available on GitHub. It is not affiliated with or endorsed by Countdown or anyone connected with the show.