Anishluke92 / RubySolution

Problem solving using Ruby programming language
0 stars 1 forks source link

24 game #49

Open danielpaul opened 3 years ago

danielpaul commented 3 years ago

This problem was asked by Twitter.

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.