20 lines
358 B
Python

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)