Are We There Yet?
A palindrome is a word or sentence that has the same sequence of letters and/or digits when it is read forward or backward; spaces, punctuation, and capitalization are usually ignored. For example, "Aha! Mob Omaha!" and the very short "Lion Oil" are palindromes.
Consider a six-digit odometer in a car that displays the total number of miles the car has been driven; no digits are displayed for fractional miles. Also ignore leading non-significant zeros in the odometer reading, so that "002345" is considered the same as "2345". With these rules, some odometer readings, such as "002332" or "056765" are palindromes. Also note that some of these palindromic numbers have an even number of digits and others have an odd number of digits.
Given the current odometer reading on a car, calculate the number of miles the car must be driven to cause the odometer to display a palindrome.
Example: The current odometer reading is 005432. The next odometer reading that will be a palindrome is 005445, so the number of miles that must be driven is 13.
The problem: Write a program that reads an odometer reading and displays the number of miles to the next odometer reading that will be a palindrome, and that palindrome.
Input
There will be an arbitrary number of odometer readings in the input, each given as a line containing 6 decimal digits and the end of line character. A line containing -1 and the end of line character will follow the last odometer reading.
Output
For each odometer reading in the input, calculate the number of miles to the closest odometer reading that is a palindrome. Display the input case number (1, 2, …), the number of miles that must be driven, and the corresponding palindromic odometer reading. Follow the format of the output shown below in the sample.