A high-security vault logs a single audit total after a suspicious series of combination attempts. Investigators believe the total may have come from someone entering a valid code together with that code's "mirror twin": the integer obtained by writing the code's decimal digits in reverse order and dropping any leading zeros that result (so the mirror twin of 340 is 43, and the mirror twin of 5 is 5). Given the audit total, decide whether some non-negative integer code exists whose value plus its mirror twin equals that total.
A single line containing one integer target.
Print true if there exists a non-negative integer code such that code + mirror(code) == target, where mirror(code) reverses the decimal digits of code and drops any resulting leading zeros. Otherwise print false.
Example 1
Input
443
Expected
true
Explanation
code = 172 has mirror twin mirror(172) = 271, and 172 + 271 = 443, so the target is achievable and the answer is true.
Example 2
Input
63
Expected
false
Explanation
Checking every candidate code from 0 up through 63 shows none of them satisfies code + mirror(code) = 63, 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 →