Skip to content

Instantly share code, notes, and snippets.

@irissilvermoon
Created April 3, 2013 18:33
Show Gist options
  • Save irissilvermoon/5303865 to your computer and use it in GitHub Desktop.
Save irissilvermoon/5303865 to your computer and use it in GitHub Desktop.
palindrome program
def palindrome?(string)
head = 0
tail = string.length - 1
while string[head] == string[tail]
head += 1
tail -= 1
if tail < head
puts 'palindrome'
else
puts 'not palindrome'
end
end
end
palindrome?("racecar")
palindrome?("hello")
palindrome?("race car")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment