A Man, A Plan, A Canal--Panama!

Difficulty:
Easy

Tags:
strings

Instructions:
A palindrome is a string that is written the same forward as it is in reverse. Write a method to return the longest palindrome in a given string

Code:
___

assert_equal longest_palindrome("xyzzy"), "yzzy"
assert_equal longest_palindrome("afbbbfjdjklgdfdhfdkjfffhhfffjkdfhdhkyejejfjkd"), "dhfdkjfffhhfffjkdfhd"
assert_equal longest_palindrome("bartarcarracecarbartar"), "racecar"
assert_equal longest_palindrome("3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982"), "46264"

Your Solution

Ruby 1.9.3

Back to Problems