Somebody asked in some channel:
“Given six numbers: 1, 2, 3, 4, 5, 22; and 5 operators: +, -, ×, ÷ and =. Is it possible to arrange these numbers and operators into a statement that is true? You must use all of the numbers and operators given.
Example: 1 + 2 - 3 × 4 ÷ 5 = 22 (not true)”
My approach
SPOILER ALERT!
At first I tried to sort the numbers and operators manually but with no luck.
I wrote a quick Python script to programmatically generate all possible statements and evaluate all of them.
|
|
The code is horribly unoptimized and ugly, but at least it gets the job done…
The code prints out a total of 86400 statements. After searching the output dump, it looks like none of them is true.
Afterwords
I wonder if these kinds of problems are possible to mathematically prove that there are no solutions (or otherwise)? If you do came up with a different approach, I would love to see it.
← Go to parent