Skip to content

Commit 403a6df

Browse files
committed
added all missing advent of code solutions
1 parent 3d33564 commit 403a6df

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+6601
-10
lines changed

carl/01/golf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
b=c=d=e=0;f=abs;g=[0,-1,0,1]
2-
for m in open("input.txt").read().split(", "):e+=2-3**(m[0]=="R");exec"g+=[(c,d)]*(0**b);c+=g[e%4];d-=g[~e%4];b=(b,f(c)+f(d))[(c,d)in g];"*int(m[1:])
3-
print f(c)+f(d),"\n",b
1+
b=c=d=e=f=0;g=[0,-1,0,1]
2+
for m in open("input.txt").read().split(", "):e+=2-3**(m[0]>"Q");exec"h=c,d;c+=g[e%4];d-=g[~e%4];b=(b,f)[h in g];g+=[h]*(0**b);f=abs(c)+abs(d);"*int(m[1:])
3+
print f,"\n",b

carl/02/golf_readable.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
l=7*[0]+[1,0,0,0,2,3,4,0,5,6,7,8,9,0,"A","B","C",0,0,0,"D"]+7*[0]
2+
q=4*[0]+range(10)+5*[0]
3+
x=9
4+
n=20
5+
i=k=""
6+
for c in open("input.txt").read():
7+
if c=="\n":
8+
i+=str(l[n])
9+
k+=`q[x]`
10+
continue
11+
f,t=((2-3**(c>"T"),0),(0,(2-3**(c<"M"))))["K"<c<"S"]
12+
g=t+3*f
13+
t+=5*f
14+
if q[x+g]:x+=g
15+
if l[n+t]:n+=t
16+
print k,"\n",i

carl/03/golf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
m=[int(s)for s in open("input.txt").read().split()]
2-
s='sum([x+y>z and x+z>y and z+y>x for '
3-
exec'print %sx,y,z in zip(m[::3],m[1::3],m[2::3])]),"\\n",%si in 0,1,2 for x,y,z in zip(m[i::9],m[3+i::9],m[6+i::9])])'%(s,s)
1+
s='map(int,open("input.txt").read().split())[i+%d*'
2+
l=0,1,2
3+
exec'print sum([x+y>z for i in%sfor x,y,z in map(sorted,zip(%s))]);'*2%("[0]",(s+"1::3],")*3%l,l,(s+"3::9],")*3%l)

carl/04/golf.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
a=map(chr,range(97,123))
21
y=z=0
32
for l in open("input.txt").readlines():
4-
p=l.rfind("-");x=l[p+1:];s=l[:p];q=['']*99
5-
for i in a:q[s.count(i)]+=i
6-
c=int(x[:-8])*("".join(q[::-1])[:5]in x);y+=c;z+=c*("north"in"".join([a[(ord(i)-97+c)%26]for i in s]))
3+
p=l.rfind("-");q=['']*9
4+
for i in map(chr,range(97,123)):q[8-l[:p].count(i)]+=i
5+
c=-int(l[p:-8]);y+=c*("".join(q)[:5]in l[p:])
6+
if(ord(l[0])-97+c)%26==13:z=c
77
print y,"\n",z

carl/04/sample.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
aaaaa-bbb-z-y-x-123[abxyz]
2+
a-b-c-d-e-f-g-h-987[abcde]
3+
not-a-real-room-404[oarel]
4+
totally-real-room-200[decoy]

carl/05/golf.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import md5
2+
c=0
3+
n=""
4+
m=[c]*16
5+
while 0 in m:
6+
h=md5.new("ugkcyxxp%d"%c).hexdigest();c+=1
7+
if h[:5]=="0"*5:
8+
n+=h[5];q=int(h[5],16)
9+
if m[q]<1:m[q]=h[6]
10+
print n[:8],"\n","".join(m)[:8]

carl/05/run.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
5+
from hashlib import *
6+
id=0
7+
pw="abc%d"
8+
pw="ugkcyxxp%d"
9+
code = ""
10+
code2 = ["_"for i in [0]*16]
11+
while 1:
12+
h=md5(pw%id).hexdigest()
13+
if h[:5]=="0"*5:
14+
code+=h[5]
15+
q=int(h[5],16)
16+
code2[int(h[5],16)]=(code2[q],h[6])[code2[q]=="_"]
17+
print id,h,code,"".join(code2)
18+
if "_" not in code2[:8]:
19+
break
20+
id+=1
21+
print code[:8]
22+
print "".join(code2)[:8]
23+
24+

carl/06/golf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
a=[[(s.count(l),l)for l in s]for s in zip(*open("input.txt").readlines())];print"".join(zip(*map(max,a)+map(min,a))[1])

0 commit comments

Comments
 (0)