Skip to content

Instantly share code, notes, and snippets.

@dabonka
Created May 17, 2018 11:07
Show Gist options
  • Save dabonka/197895a81f801baa22196cd9a4fa7c3e to your computer and use it in GitHub Desktop.
Save dabonka/197895a81f801baa22196cd9a4fa7c3e to your computer and use it in GitHub Desktop.
def check(str1, str2)
str1.reverse == str2
# str1[0] # D
# str2[-1] # D
# str1[1] # D
# str2[-2] # D
# str1[2] # D
# str2[-3] # D
# str1[i] # D
# str2[-1 - i] # D
if str1.length == str2.length
i = 0
while i < (str1.length - 1) do
if str1[i] == str2[-1-i]
if str1[i] == str1.length
return true
end
i +=1
else
return false
end
end
else
return false
end
return true
end
puts check('DOM', 'MOD') # => true
puts check('S1SSS', 'SSS1S') # => true
puts check('QWER', 'RWQE') # => false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment