Skip to content

Latest commit

 

History

History
26 lines (22 loc) · 928 Bytes

they_say_that_only_the_name_is_long_enough_to_attract_attention_they_also_said_that_only_a_simple_kata_will_have_someone_to_solve_it_this_is_a_sadly_story_№1_are_they_opposite.md

File metadata and controls

26 lines (22 loc) · 928 Bytes

Description

Task

Give you two strings: s1 and s2. If they are opposite, return true; otherwise, return false. Note: The result should be a boolean value, instead of a string.

The opposite means: All letters of the two strings are the same, but the case is opposite. you can assume that the string only contains letters or it's a empty string. Also take note of the edge case - if both strings are empty then you should return false/False.

Examples (input -> output)

"ab","AB"     -> true
"aB","Ab"     -> true
"aBcd","AbCD" -> true
"AB","Ab"     -> false
"",""         -> false

My Solution

def is_opposite(s1, s2)
  s1 == s2.swapcase!
end