python/CodeChallenge_7.py

19 lines
473 B
Python

class Solution:
def solve(self, n:int) -> int:
print(f"n: {n}")
'''
find how many (a, b) are possible where a + b = n
n = 3 -> (1, 2), (2, 1)
n = 4 -> (1, 3), (2, 2), (3, 1)
'''
a = 1
count = 0
while n - a > 0:
a += 1
count += 1
return count
s = Solution()
print(s.solve(3)) # Output: 2
print(s.solve(4)) # Output: 3
print(s.solve(5)) # Output: 4