Palindrome range solution in scala