This page is a permanent link to the reply below and its nested replies. See all post replies »
DDonde · 31-35, M
for i is 100 to 1000
For each digit left of middle, push to stack
If it's odd length, ignore the middle digit
For every digit after middle, check to see if it matches the top of the stack and pop it if it does. If there is a mismatch, it's not a palindrome. Or if the stack is not empty at the end, it is not a palindrome.
If it the stack is empty by the end, add 1 to the count of palindromes.
Clear the stack. Next number.
For each digit left of middle, push to stack
If it's odd length, ignore the middle digit
For every digit after middle, check to see if it matches the top of the stack and pop it if it does. If there is a mismatch, it's not a palindrome. Or if the stack is not empty at the end, it is not a palindrome.
If it the stack is empty by the end, add 1 to the count of palindromes.
Clear the stack. Next number.