feat: add same_case function and tests

This commit is contained in:
mafs1722 2026-02-26 21:48:59 +01:00
parent 12f91d7845
commit c3b326c9a0
2 changed files with 18 additions and 0 deletions

10
src/same_case.py Normal file
View File

@ -0,0 +1,10 @@
# https://www.codewars.com/kata/5dd462a573ee6d0014ce715b
def same_case(a, b):
if not a.isalpha() or not b.isalpha():
return -1
if (a.islower() and b.islower()) or (a.isupper() and b.isupper()):
return 1
return 0

8
tests/test_same_case.py Normal file
View File

@ -0,0 +1,8 @@
from src.same_case import same_case
def test_same_case():
assert same_case('a', 'g') == 1
assert same_case('A', 'C') == 1
assert same_case('b', 'G') == 0
assert same_case('B', 'g') == 0
assert same_case('0', '?') == -1