Rename three sum (#354)

Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com>
This commit is contained in:
merwanehamadi
2023-09-04 19:50:27 -07:00
committed by GitHub
parent 2dc1a0a9cd
commit 0bb45be584
43 changed files with 6 additions and 6 deletions

View File

@@ -0,0 +1,32 @@
# mypy: ignore-errors
from typing import List
from sample_code import three_sum
def test_three_sum(nums: List[int], target: int, expected_result: List[int]) -> None:
result = three_sum(nums, target)
print(result)
assert (
result == expected_result
), f"AssertionError: Expected the output to be {expected_result}"
if __name__ == "__main__":
# test the trivial case with the first three numbers
nums = [2, 7, 11, 15]
target = 20
expected_result = [0, 1, 2]
test_three_sum(nums, target, expected_result)
# test for ability to use zero and the same number twice
nums = [2, 7, 0, 15, 12, 0]
target = 2
expected_result = [0, 2, 5]
test_three_sum(nums, target, expected_result)
# test for first and last index usage and negative numbers
nums = [-6, 7, 11, 4]
target = 9
expected_result = [0, 2, 3]
test_three_sum(nums, target, expected_result)