matsagad / countdown-solver

A React app that solves the Countdown Numbers Game.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Countdown Solver

Demo Video

A React app that finds and displays the best answer to the Countdown Numbers Game. The given solution conforms to the Countdown rules (i.e. integers as answers, no fractional intermediate steps, basic operations only, and all numbers need not be used). If no exact answer is found, the closest one is provided. Try it out here.

Algorithm

A dynamic programming strategy is done by: splitting the numbers into two groups, finding all unique values a group could evaluate to (with their corresponding expressions), and recording all possible results when two groups are combined. Pairs of numbers are first considered, then, successively, every combination is solved until a combination of all the numbers is reached.

Initially, as in OldBoard.js, all valid polish notation expressions were evaluated by considering all the number permutations and choices for operations. In hindsight, this was inefficient in that for every permutation, the next to consider often only swaps two values. This means, apart from the non-commutative operations, everything else evaluates the same. By considering each individual combination instead, we eliminate the redundancy of recording values that the other numbers can make up.

Other

Color palette used is Cyber Ping Pong by sukinapan.

About

A React app that solves the Countdown Numbers Game.


Languages

Language:JavaScript 79.4%Language:CSS 16.4%Language:HTML 4.2%