Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kaliane/two sum #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion functions/two_sum.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
def twoSum(n, t):
pass
for i in range(len(n)):
for j in range(i + 1, len(n)):
if n[j] == t - n[i]:
return [i, j]
25 changes: 25 additions & 0 deletions tests/two_sum_test.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,27 @@
import pytest
from functions.two_sum import twoSum

def test_returns_1_2_for_3_2_4_with_target_6():
# Arrange
n = [3, 2, 4]
t = 6

# Act
answer = twoSum(n, t)

# Assert
assert answer == [1, 2]


def test_returns_0_1_for_3_3_with_target_6():
# Arrange
n = [3, 3]
t = 6

# Act
answer = twoSum(n, t)

# Assert
assert answer == [0, 1]