finish extra/numbers-station-coded-messages
Submitting solution... Submission: SUCCESSFUL. Completed in: 10 mins, 1 secs.
This commit is contained in:
parent
70be0c07d8
commit
0d002d6988
@ -102,3 +102,6 @@ CFcSBwgCCBoHRhkKU1cGAA4AGU5YQR5THBwNFwoGGAxTQQMQVBUSBg4EAAwQRhUQVBUHFAQTGRpT QQM
|
|||||||
|
|
||||||
### dont-get-volunteered
|
### dont-get-volunteered
|
||||||
* Completed in: 2 hrs, 56 mins, 6 secs.
|
* Completed in: 2 hrs, 56 mins, 6 secs.
|
||||||
|
|
||||||
|
### numbers-station-coded-messages
|
||||||
|
* Completed in: 10 mins, 1 secs.
|
||||||
|
|||||||
15
extra/numbers-station-coded-messages/solution.py
Normal file
15
extra/numbers-station-coded-messages/solution.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
def solution(l, t):
|
||||||
|
for i in range(len(l)):
|
||||||
|
for j in range(i, len(l)):
|
||||||
|
if sum(l[i:j+1]) == t:
|
||||||
|
return [i, j]
|
||||||
|
return [-1, -1]
|
||||||
|
|
||||||
|
tests = [
|
||||||
|
([[1, 2, 3, 4], 15], [-1, -1]),
|
||||||
|
([[4, 3, 10, 2, 8], 12], [2, 3]),
|
||||||
|
]
|
||||||
|
|
||||||
|
for i, o in tests:
|
||||||
|
result = solution(*i)
|
||||||
|
print (i, result == o, result, o)
|
||||||
Loading…
x
Reference in New Issue
Block a user