For our inaugural weekly coding challenge, we’re starting with a classic. A palindrome is a sequence of characters that is the same both forwards and backwards. Examples of this are the words ‘racecar’ and ‘madam’ or numbers like 101, 111, 2882, and many, many more.
Challenge 1: Write a program that reads in a word or number as input and then prints “palindrome” or “not palindrome” corresponding to whether that word or number is a palindrome.
Now imagine the sequences ‘abab’ and ‘cdeec’. In both cases, these can be turned into palindromes by swapping one pair of letters, namely ‘abba’ (or ‘baab’) and ‘cedec’.
Challenge 2: Write a program that reads in a word or number as input that is one swap away from being a palindrome, and then find the right swap and perform it to output that word as a palindrome.