Daily Coding Day Three Thirty Four
This problem was asked by Twitter. Most of these interviews sound like a real fun time. This one is at least a game, but how I wish there was less LBJ style technical interviewing. I think one of the real gotchas here would be floating point precision, because we have to include division. JS solution is after the text. Almost ‘25 time!
The 24 game is played as follows. You are given a list of four integers, each between 1 and 9, in a fixed order. By placing the operators +, -, *, and / between the numbers, and grouping them with parentheses, determine whether it is possible to reach the value 24.
For example, given the input [5, 2, 7, 8], you should return True, since (5 * 2 - 7) * 8 = 24.
Write a function that plays the 24 game.
1 | function canReach24(nums) { |