Chucky's JavaScript 24-Points Solver!
24 Points is a card game where players randomly draw 4 cards at a time
from the deck. Aces are low, with a value of 1, and Kings are high with
a value of 13. The goal is to use each card exactly once to find a result
of exactly 24 by adding, subtracting, multiplying, or dividing the values.
The cards may be used in any order, and parentheses may be used to change
the order of operations.
Example:
2, 3, 4, 8...one possible solution is (4 - 3 + 2) * 8 = 24
Notes:
+, -, *, and / are add, subtract, multiply, and divide, respectively.
Due to rounding errors, I check to see if a number is close to 24 rather
than exactly equal to 24. The tolerance can be adjusted, but it should
work fine with the default value. (leave the tolerance box empty).
Since - and / don't commute, I added two new operators <- and </ to
indicate backwards subtraction and division. So 3 </ 6 = 2. This made
the code a bit simpler to write.
Return to my home page.
Last Modified 7/14/2001
©2001 Charlton Sun
Please don't rip my page off without asking first...
not that there's anything on this page actually worth taking...