diff --git a/README.md b/README.md index f756f83..543eb5d 100644 --- a/README.md +++ b/README.md @@ -102,3 +102,6 @@ CFcSBwgCCBoHRhkKU1cGAA4AGU5YQR5THBwNFwoGGAxTQQMQVBUSBg4EAAwQRhUQVBUHFAQTGRpT QQM ### dont-get-volunteered * Completed in: 2 hrs, 56 mins, 6 secs. + +### numbers-station-coded-messages +* Completed in: 10 mins, 1 secs. diff --git a/extra/numbers-station-coded-messages/solution.py b/extra/numbers-station-coded-messages/solution.py new file mode 100644 index 0000000..0c9b56f --- /dev/null +++ b/extra/numbers-station-coded-messages/solution.py @@ -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)