Discussion
· Sep 19, 2022

[Code Challenge] Are they opposite?

Hello, community

To celebrate that this week is "International Week of Deaf People 2022" , https://wfdeaf.org/iwdeaf2022/

Could we do a small challenge?

The statement is:

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

 

 

 

🧏🧑‍💻📍 This programming exercise has been taken from: https://www.codewars.com/kata/574b1916a3ebd6e4fa0012e7

 

We hope you enjoy this challenge

Thanks for your time

Discussion (3)1
Log in or sign up to continue