Created
March 21, 2018 04:18
-
-
Save whatalnk/a6e9dd7485258a62cde679cfc3f67d03 to your computer and use it in GitHub Desktop.
CODE THANKS FESTIVAL 2017(Parallel) B. Concatenated Palindrome
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
s = gets.chomp | |
ss = s.reverse | |
ans = ss.length | |
ss.length.times do |i| | |
sss = s + ss[i..-1] | |
if sss == sss.reverse then | |
ans = ss.length - i | |
end | |
end | |
if s == ss then | |
puts 0 | |
else | |
puts ans | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment