[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Request for Algorithm




Dear vnsa friends,

Can someone provide an algorithm that:

1. Given as input, four numbers, all greater than zero,
2. Using four arithmetic operators +, -, *, /.

Answer yes or no if there is a way to come up with 24 using the four   
input
numbers and the four arithmetic operators. Each number must be used   
exatcly
one, and the result of one computation can be used in the next.

If the answer if Yes, print the calculation.

Examples,

1. Input:  1,2,3,4.
    Answer: Yes:  (1+2+3)*4

2. Input: 2,2,2,2.
    Answer: No.


Regards,

Ninh