diff options
| author | n1c00o <git.n1c00o@gmail.com> | 2021-10-06 18:54:24 +0200 |
|---|---|---|
| committer | n1c00o <git.n1c00o@gmail.com> | 2021-10-06 18:54:24 +0200 |
| commit | f14e8b4a5d0df4a6702ae0e7f2a97c04a25f336a (patch) | |
| tree | 6a0dd99cfd074d59a06b60c773435b745e0dbe5d | |
| parent | 9e98b6957545155a542b5bf2c47f128c470d7482 (diff) | |
Start sol for numbers-station-coded-messages
| -rw-r--r-- | numbers-station-coded-messages/solution.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/numbers-station-coded-messages/solution.py b/numbers-station-coded-messages/solution.py index 91baecd..716e05e 100644 --- a/numbers-station-coded-messages/solution.py +++ b/numbers-station-coded-messages/solution.py @@ -1,2 +1,18 @@ -def solution(l, t): - # Your code here +def solution(l, t): + for start_i in range(len(l)): + sum = l[start_i] + + for curr_i in range(start_i + 1, len(l), 1): + sum += l[curr_i] + + if sum == t: + return [start_i, curr_i] + elif sum > t: + break + + return [-1, -1] + + +# tests +assert solution([1, 2, 3, 4], 15) == [-1, -1], "Test 1 failed" +assert solution([4, 3, 10, 2, 8], 12) == [2, 3], "Test 2 failed" |
