Last active
June 13, 2023 13:39
-
-
Save owalacesilva/fef1e331a7d251e20dec61a13262562c to your computer and use it in GitHub Desktop.
Palindrome word
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def palindrome?(word) | |
initial_word = word.downcase.gsub(/[^a-z0-9]/, '') | |
reversed_word = initial_word.reverse | |
initial_word == reversed_word | |
end | |
puts 'Typing a word:' | |
input = gets.chomp | |
if palindrome?(input) | |
puts "\"#{input}\" is a palindrome word." | |
else | |
puts "\"#{input}\" is not a palindrome word." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment