diff options
author | tomsmeding <tom.smeding@gmail.com> | 2016-12-11 21:18:47 +0100 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2016-12-11 21:18:47 +0100 |
commit | 97b4c5d86cc12447ac6845e25a863e26a88aec35 (patch) | |
tree | 75d65b173b02ce590e9f845addf762ba2c473f78 /9a.py | |
parent | 866bfb0aca286da74d2c82cc88ffaf08e6068193 (diff) |
7b 8 9a
Diffstat (limited to '9a.py')
-rwxr-xr-x | 9a.py | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -0,0 +1,21 @@ +#!/usr/bin/env python3 + +import sys + +def decomplen(s): + total=0 + i=0 + while i<len(s): + if s[i]=="(": + closeidx=s.index(")",i+1) + marker=[int(x) for x in s[i+1:closeidx].split("x")] + repstr=s[closeidx+1:closeidx+1+marker[0]] + total+=marker[1]*len(repstr) + i=closeidx+1+marker[0] + else: + total+=1 + i+=1 + + return total + +print(decomplen(sys.stdin.readline()[:-1])) |