diff options
-rw-r--r-- | 2016/1.in (renamed from 1.in) | 0 | ||||
-rw-r--r-- | 2016/1a.out (renamed from 1a.out) | 0 | ||||
-rwxr-xr-x | 2016/1a.py (renamed from 1a.py) | 0 | ||||
-rw-r--r-- | 2016/1a.rip (renamed from 1a.rip) | 0 | ||||
-rw-r--r-- | 2016/1b.out (renamed from 1b.out) | 0 | ||||
-rwxr-xr-x | 2016/1b.py (renamed from 1b.py) | 0 | ||||
-rw-r--r-- | 2016/2.in (renamed from 2.in) | 0 | ||||
-rw-r--r-- | 2016/2a.out (renamed from 2a.out) | 0 | ||||
-rwxr-xr-x | 2016/2a.py (renamed from 2a.py) | 0 | ||||
-rw-r--r-- | 2016/2b.out (renamed from 2b.out) | 0 | ||||
-rwxr-xr-x | 2016/2b.py (renamed from 2b.py) | 0 | ||||
-rw-r--r-- | 2016/3.in (renamed from 3.in) | 0 | ||||
-rw-r--r-- | 2016/3a.out (renamed from 3a.out) | 0 | ||||
-rwxr-xr-x | 2016/3a.py (renamed from 3a.py) | 0 | ||||
-rw-r--r-- | 2016/3b.out (renamed from 3b.out) | 0 | ||||
-rwxr-xr-x | 2016/3b.py (renamed from 3b.py) | 0 | ||||
-rw-r--r-- | 2016/4.in (renamed from 4.in) | 0 | ||||
-rw-r--r-- | 2016/4a.out (renamed from 4a.out) | 0 | ||||
-rwxr-xr-x | 2016/4a.py (renamed from 4a.py) | 0 | ||||
-rw-r--r-- | 2016/4b.out (renamed from 4b.out) | 0 | ||||
-rwxr-xr-x | 2016/4b.py (renamed from 4b.py) | 0 | ||||
-rw-r--r-- | 2016/5.in (renamed from 5.in) | 0 | ||||
-rw-r--r-- | 2016/5a.c (renamed from 5a.c) | 0 | ||||
-rw-r--r-- | 2016/5a.out (renamed from 5a.out) | 0 | ||||
-rw-r--r-- | 2016/5b.c (renamed from 5b.c) | 0 | ||||
-rw-r--r-- | 2016/5b.out (renamed from 5b.out) | 0 | ||||
-rw-r--r-- | 2016/6.in (renamed from 6.in) | 0 | ||||
-rw-r--r-- | 2016/6a.out (renamed from 6a.out) | 0 | ||||
-rwxr-xr-x | 2016/6a.py (renamed from 6a.py) | 0 | ||||
-rw-r--r-- | 2016/6b.out (renamed from 6b.out) | 0 | ||||
-rwxr-xr-x | 2016/6b.py (renamed from 6b.py) | 0 | ||||
-rw-r--r-- | 2016/7.in (renamed from 7.in) | 0 | ||||
-rw-r--r-- | 2016/7a.out (renamed from 7a.out) | 0 | ||||
-rwxr-xr-x | 2016/7a.py (renamed from 7a.py) | 0 | ||||
-rw-r--r-- | 2016/7b.out (renamed from 7b.out) | 0 | ||||
-rwxr-xr-x | 2016/7b.py (renamed from 7b.py) | 0 | ||||
-rw-r--r-- | 2016/8.in (renamed from 8.in) | 0 | ||||
-rw-r--r-- | 2016/8a.out (renamed from 8a.out) | 0 | ||||
-rwxr-xr-x | 2016/8a.py (renamed from 8a.py) | 0 | ||||
-rw-r--r-- | 2016/8b.out (renamed from 8b.out) | 0 | ||||
-rwxr-xr-x | 2016/8b.py (renamed from 8b.py) | 0 | ||||
-rw-r--r-- | 2016/9.in (renamed from 9.in) | 0 | ||||
-rw-r--r-- | 2016/9a.out (renamed from 9a.out) | 0 | ||||
-rwxr-xr-x | 2016/9a.py (renamed from 9a.py) | 0 | ||||
-rw-r--r-- | 2016/9b.out | 1 | ||||
-rwxr-xr-x | 2016/9b.py | 21 | ||||
-rw-r--r-- | 2016/Makefile (renamed from Makefile) | 0 | ||||
-rwxr-xr-x | 2016/test.sh (renamed from test.sh) | 0 |
48 files changed, 22 insertions, 0 deletions
diff --git a/2016/9b.out b/2016/9b.out new file mode 100644 index 0000000..534bc25 --- /dev/null +++ b/2016/9b.out @@ -0,0 +1 @@ +10762972461 diff --git a/2016/9b.py b/2016/9b.py new file mode 100755 index 0000000..9df3005 --- /dev/null +++ b/2016/9b.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]*decomplen(repstr) + i=closeidx+1+marker[0] + else: + total+=1 + i+=1 + + return total + +print(decomplen(sys.stdin.readline()[:-1])) |