Oct 92 Challenge
Volume Number: 8
Issue Number: 6
Column Tag: Programmers' Challenge
Programmers' Challenge
By Mike Scanlin, MacTutor Regular Contributing Author
Note: Source code files accompanying article are located on MacTech CD-ROM orsource code disks.
Programming Challenge of the Month - NAME NO ONE MAN
This month’s challenge involves palindromes -- things that read the same
backward and forward (like the letters in “name no one man” or “a toyota”). The goal
is to write a routine that finds the nth palindrome greater than a given baseNumber
(when it’s displayed as a base 10 integer without leading zeros). Our numeric
palindromes will only consist of digits from 0 to 9 and will not be larger than 9 digits
long (return -1 if the palindrome requested is larger than 999,999,999). The
prototype is:
long FindNthPalindrome(baseNumber, n)
long baseNumber;
short n;
Example:
Input: baseNumber = 107
n = 3
Output:
function result = 131
Remember, speed is more important than size. This is a fairly simple
programming challenge -- but how fast can you make it?
Congratulations
To Aaron Zick (San Francisco, CA) for winning the very first MacTutor
Programming Challenge (rubber banded pegs). Among the submitted solutions yielding
correct results, his was the fastest and the second smallest. He will be receiving a cool