finish extra/en-route-salute #18
@ -82,3 +82,6 @@ CFcSBwgCCBoHRhkKU1cGAA4AGU5YQR5THBwNFwoGGAxTQQMQVBUSBg4EAAwQRhUQVBUHFAQTGRpT QQM
|
|||||||
|
|
||||||
### ion-flux-relabeling
|
### ion-flux-relabeling
|
||||||
* Completed in: 9 hrs, 33 mins, 36 secs.
|
* Completed in: 9 hrs, 33 mins, 36 secs.
|
||||||
|
|
||||||
|
### en-route-salute
|
||||||
|
* Completed in: 7 mins, 15 secs.
|
||||||
|
|||||||
19
extra/en-route-salute/solution.py
Normal file
19
extra/en-route-salute/solution.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
def solution(s):
|
||||||
|
result = 0
|
||||||
|
count = 0
|
||||||
|
for c in s:
|
||||||
|
if c == '>':
|
||||||
|
count += 1
|
||||||
|
if c == '<':
|
||||||
|
result += count
|
||||||
|
return 2 * result
|
||||||
|
|
||||||
|
tests = [
|
||||||
|
(">----<", 2),
|
||||||
|
("<<>><", 4),
|
||||||
|
("--->-><-><-->-", 10),
|
||||||
|
]
|
||||||
|
|
||||||
|
for i, o in tests:
|
||||||
|
result = solution(i)
|
||||||
|
print (i, result == o, result, o)
|
||||||
Loading…
x
Reference in New Issue
Block a user