Question: 24 game using only C language! 24 is a mental arithmetic game, first played using poker cards. Given four integers, the objective is to produce

24 game using only C language!

24 is a mental arithmetic game, first played using poker cards. Given four integers, the objective is to produce the number 24 using the standard arithmetic operators (+, -, * and /), while consuming all four numbers in the process.

For example, given the numbers { 2, 3, 5, 6 }, one can do:

2 * 3 = 6

5 * 6 = 30

30 - 6 = 24

There are often many solutions to a problem. Can you see another way to get 24 from the numbers above?

(As per the rules of the game, the order that the integers are given does not affect the reachability of 24.)

In this challenge, you will write a program that takes in four integers, and determines whether it is possible to reach 24 from those numbers. You can assume the number 0 will not form part of the input.

Example 1

Enter 4 integers: 2 3 5 6 Yes! 24 is reachable from { 2, 3, 5, 6 } 

Example 2

Enter 4 integers: 1 1 1 1 Noooo :( 24 is unreachable from { 1, 1, 1, 1 } 

Example 3

Enter 4 integers: hello Input must consist of 4 integers 

Hints

Think before you write

Test before you submit

Recursion is your friend

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!