summaryrefslogtreecommitdiff
path: root/9a.py
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2016-12-11 21:18:47 +0100
committertomsmeding <tom.smeding@gmail.com>2016-12-11 21:18:47 +0100
commit97b4c5d86cc12447ac6845e25a863e26a88aec35 (patch)
tree75d65b173b02ce590e9f845addf762ba2c473f78 /9a.py
parent866bfb0aca286da74d2c82cc88ffaf08e6068193 (diff)
7b 8 9a
Diffstat (limited to '9a.py')
-rwxr-xr-x9a.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/9a.py b/9a.py
new file mode 100755
index 0000000..2bba4a2
--- /dev/null
+++ b/9a.py
@@ -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]))