A reactor test bench lines up fuel rods in a row, each stamped with a single charge digit from 0 to 9, written together as a digit string s. To calibrate the bench, engineers repeatedly run a fusion pass over the row: each pass produces a new row, one rod shorter than before, where the value at every position is the sum of the two rods that were adjacent to it in the previous row, taken modulo 10. Passes continue until exactly two rods remain in the row. Determine whether those two final rods carry equal charge.
A single line containing the digit string s.
Print "true" if the two digits remaining after all fusion passes are equal, and "false" otherwise.
Example 1
Input
1991
Expected
true
Explanation
Pass 1 turns "1991" into "(1+9)%10, (9+9)%10, (9+1)%10" = "0", "8", "0", giving "080". Pass 2 turns "080" into "(0+8)%10, (8+0)%10" = "8", "8", giving "88". The two final digits are equal, so the answer is true.
Example 2
Input
5281
Expected
false
Explanation
Pass 1 turns "5281" into "(5+2)%10, (2+8)%10, (8+1)%10" = "7", "0", "9", giving "709". Pass 2 turns "709" into "(7+0)%10, (0+9)%10" = "7", "9", giving "79". The two final digits differ, so the answer is false.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →