Sahil and Amrit are friends. One day Amrit comes to Sahil’s home to take him outside so that they can play together. But Sahil denies saying that he will not play unless he reaches to the solution of the problem he is stucked with. So, Amrit decides to help him out .The problem is, given the first 50 natural numbers i.e., 1 , 2 , . . . . . . . 49 , 50 which are written on a board. Select two of the numbers on the board, say a and b , write the absolute value of their difference |a – b| on the board and then erase both a and b. Apply the above operation 49 times. Determine all possible values of the remaining number that can be obtained in this manner.
Solution : Any odd positive integer which is less than 50 can be obtained.
1) As initially the numbers from 1 to 50 are on the board, so the initial sum of numbers on the board is equal to
1 + 2 + 3 + 4 + ———- +50 = 1275, which is odd.
2) As in each operation select two numbers on the board i.e, a and b where a<=b, write the absolute value of their difference |a – b| on the board, and then erase both a and b.
= – a – b + |a – b|
3) As a<=b, therefore , |a – b| = -(a – b) = b – a ,which implies :
= – a – b + b – a = – 2a ————(1)
4) From result 1, this can concluded that each operation of replacing a and b by |a – b|, where a <= b without loss of generality, decreases the sum by 2a
5) From result 1 , it is clear that the new sum must be odd if the old sum was odd, and therefore no even number can result from repeated applications of such an operation starting with 1275.
6) Also given that all the numbers on the board are always nonnegative. They are also less than or equal to 50, since |a – b| is always less than or equal to the maximum of a and b for nonnegative a and b. Now , any odd integer from 1 to 49, inclusive, can be obtained by applying the puzzle’s operation 49 times.
7) Let k be such a number. This can be obtained in the first iteration by subtracting 1 from k + 1 as | 1 – (k + 1) | = k.
8) Then, apply the operation to the pairs of the remaining consecutive integers,
(2, 3), (4, 5), . . . , (k – 1, k), (k + 2, k + 3), . . . , (49, 50), to get 24 ones on the board while erasing the above pairs.
9) As till now, the operation is applied 25 times ( 1 in step 7 and 24 in step 8). Applying the operation 12 more times to the 24 pairs of ones yields 12 zeros, which can be reduced to a single zero after applying the operation 11 times.
10) After step 9, total number of times the operation is applied is 48. Finally, applying the operation to the two remaining numbers, k and 0, yields k.
As k is odd, hence any odd positive integer which is less than 50 can be obtained after applying the given operation for 49 times.
References : Algorithmic Puzzles – Anany Levitin, Maria Levitin
- Puzzle 1 | (How to Measure 45 minutes using two identical wires?)
- Puzzle 2 | (Find ages of daughters)
- Puzzle 3 | (Calculate total distance travelled by bee)
- Puzzle 4 | (Pay an employee using a 7 units gold rod?)
- Puzzle 13 | (100 Prisoners with Red/Black Hats)
- Puzzle 5 | (Finding the Injection for Anesthesia)
- Puzzle 6 | (Monty Hall problem)
- Puzzle 7 | (3 Bulbs and 3 Switches)
- Puzzle 8 | (Find the Jar with contaminated pills)
- Puzzle 9 | (Find the fastest 3 horses)
- Puzzle 10 | (A Man with Medical Condition and 2 Pills)
- Puzzle 11 | (1000 Coins and 10 Bags)
- Puzzle 12 | (Maximize probability of White Ball)
- Puzzle 14 | (Strategy for a 2 Player Coin Game)
- Puzzle 15 | (Camel and Banana Puzzle)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.