Skip to content

Instantly share code, notes, and snippets.

@vovs03
Last active November 16, 2018 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vovs03/db24e4850adf38cdc5ecff23d99928b4 to your computer and use it in GitHub Desktop.
Save vovs03/db24e4850adf38cdc5ecff23d99928b4 to your computer and use it in GitHub Desktop.
Check Palindrome [Ruby]

Example

For inputString = "aabaa", the output should be
checkPalindrome(inputString) = true;
For inputString = "abac", the output should be
checkPalindrome(inputString) = false;
For inputString = "a", the output should be
checkPalindrome(inputString) = true.

Input/Output

[execution time limit] 4 seconds (rb)

[input] string inputString

A non-empty string consisting of lowercase characters.

Guaranteed constraints:
1 ≤ inputString.length ≤ 105.

[output] boolean
    true if inputString is a palindrome, false otherwise.
# Old name checkPalindrome.codesignal.ruby.rb
# 2018-11-15
# inputString.to_s = "abuka"
def checkPalindrome(inputString)
inputString.to_s
if inputString.reverse == inputString
puts ("#{inputString} true")
elsif
print ("#{inputString} false")
end
end
puts "Enter Palindrome"
word = gets
puts checkPalindrome(word.chomp)
@vovs03
Copy link
Author

vovs03 commented Nov 15, 2018

нужно было добавить метод .chomp [18 строка]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment