Solution to the palindromic ranges problem.