Problem 4

Palindrome part is ugly. meh.