Doing some 2015 exos for fun
This commit is contained in:
parent
f41eb99256
commit
21f447c67a
20 changed files with 4113 additions and 0 deletions
9
2015/day 1/P1/flor.py
Normal file
9
2015/day 1/P1/flor.py
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
instructions = open("input.txt").read()
|
||||||
|
flor = 0
|
||||||
|
for i in list(instructions):
|
||||||
|
if i == "(":
|
||||||
|
flor+=1
|
||||||
|
elif i == ")":
|
||||||
|
flor-=1
|
||||||
|
print(flor)
|
||||||
|
|
1
2015/day 1/P1/input.txt
Normal file
1
2015/day 1/P1/input.txt
Normal file
File diff suppressed because one or more lines are too long
10
2015/day 1/P2/flor.py
Normal file
10
2015/day 1/P2/flor.py
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
instructions = open("input.txt").read()
|
||||||
|
flor = 0
|
||||||
|
for c, i in enumerate(list(instructions)):
|
||||||
|
if i == "(":
|
||||||
|
flor+=1
|
||||||
|
elif i == ")":
|
||||||
|
flor-=1
|
||||||
|
if flor == -1:
|
||||||
|
break
|
||||||
|
print(c+1)
|
1
2015/day 1/P2/input.txt
Normal file
1
2015/day 1/P2/input.txt
Normal file
File diff suppressed because one or more lines are too long
1000
2015/day 2/P1/input.txt
Normal file
1000
2015/day 2/P1/input.txt
Normal file
File diff suppressed because it is too large
Load diff
9
2015/day 2/P1/paper.py
Normal file
9
2015/day 2/P1/paper.py
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
boxs = open("input.txt").read().split("\n")[:-1]
|
||||||
|
paper = 0
|
||||||
|
for i in list(boxs):
|
||||||
|
i = i.split("x")
|
||||||
|
dim1 = (int(i[0])*int(i[1]))
|
||||||
|
dim2 = (int(i[1])*int(i[2]))
|
||||||
|
dim3 = (int(i[2])*int(i[0]))
|
||||||
|
paper+=2*dim1+2*dim2+2*dim3+min([dim1, dim2, dim3])
|
||||||
|
print(paper)
|
1000
2015/day 2/P2/input.txt
Normal file
1000
2015/day 2/P2/input.txt
Normal file
File diff suppressed because it is too large
Load diff
6
2015/day 2/P2/ribbon.py
Normal file
6
2015/day 2/P2/ribbon.py
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
boxs = open("input.txt").read().split("\n")[:-1]
|
||||||
|
ribbon = 0
|
||||||
|
for i in boxs:
|
||||||
|
i = sorted([int(j) for j in i.split("x")])
|
||||||
|
ribbon+=(i[0]*2+i[1]*2)+(i[0]*i[1]*i[2])
|
||||||
|
print(ribbon)
|
17
2015/day 3/P1/delivering.py
Normal file
17
2015/day 3/P1/delivering.py
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
instructions = open("input.txt").read()
|
||||||
|
x = 0
|
||||||
|
y = 0
|
||||||
|
house = ["0;0"]
|
||||||
|
delivery = 0
|
||||||
|
for i in list(instructions):
|
||||||
|
if i == "^":
|
||||||
|
y+=1
|
||||||
|
elif i == "v":
|
||||||
|
y-=1
|
||||||
|
elif i == ">":
|
||||||
|
x+=1
|
||||||
|
elif i == "<":
|
||||||
|
x-=1
|
||||||
|
if f"{x};{y}" not in house:
|
||||||
|
house.append(f"{x};{y}")
|
||||||
|
print(len(house))
|
1
2015/day 3/P1/input.txt
Normal file
1
2015/day 3/P1/input.txt
Normal file
File diff suppressed because one or more lines are too long
18
2015/day 3/P2/delivering.py
Normal file
18
2015/day 3/P2/delivering.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
instructions = open("input.txt").read()
|
||||||
|
cords={"Santa": [0,0], "Robot Santa": [0,0]}
|
||||||
|
house = ["0;0"]
|
||||||
|
delivery = 0
|
||||||
|
turn = "Santa"
|
||||||
|
for i in list(instructions):
|
||||||
|
if i == "^":
|
||||||
|
cords[turn][1]+=1
|
||||||
|
elif i == "v":
|
||||||
|
cords[turn][1]-=1
|
||||||
|
elif i == ">":
|
||||||
|
cords[turn][0]+=1
|
||||||
|
elif i == "<":
|
||||||
|
cords[turn][0]-=1
|
||||||
|
if f"{cords[turn][0]};{cords[turn][1]}" not in house:
|
||||||
|
house.append(f"{cords[turn][0]};{cords[turn][1]}")
|
||||||
|
turn = "Santa" if turn == "Robot Santa" else "Robot Santa"
|
||||||
|
print(len(house))
|
1
2015/day 3/P2/input.txt
Normal file
1
2015/day 3/P2/input.txt
Normal file
File diff suppressed because one or more lines are too long
6
2015/day 4/P1/AdventCoins.py
Normal file
6
2015/day 4/P1/AdventCoins.py
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
import hashlib
|
||||||
|
key = open("input.txt").read().replace("\n", "")
|
||||||
|
num=0
|
||||||
|
while hashlib.md5(f"{key}{num}".encode()).hexdigest()[:5] != "00000":
|
||||||
|
num+=1
|
||||||
|
print(num)
|
1
2015/day 4/P1/input.txt
Normal file
1
2015/day 4/P1/input.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
yzbqklnj
|
6
2015/day 4/P2/AdventCoins.py
Normal file
6
2015/day 4/P2/AdventCoins.py
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
import hashlib
|
||||||
|
key = open("input.txt").read().replace("\n", "")
|
||||||
|
num=0
|
||||||
|
while hashlib.md5(f"{key}{num}".encode()).hexdigest()[:6] != "000000":
|
||||||
|
num+=1
|
||||||
|
print(num)
|
1
2015/day 4/P2/input.txt
Normal file
1
2015/day 4/P2/input.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
yzbqklnj
|
1000
2015/day 5/P1/input.txt
Normal file
1000
2015/day 5/P1/input.txt
Normal file
File diff suppressed because it is too large
Load diff
11
2015/day 5/P1/string.py
Normal file
11
2015/day 5/P1/string.py
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
strings = open("input.txt").read().split("\n")[:-1]
|
||||||
|
nice = 0
|
||||||
|
for i in strings:
|
||||||
|
if i.count("a")+i.count("e")+i.count("i")+i.count("o")+i.count("u") >= 3 \
|
||||||
|
and not ("ab" in i or "cd" in i or "pq" in i or "xy" in i):
|
||||||
|
for j in list(i):
|
||||||
|
if f"{j}{j}" in i:
|
||||||
|
nice+=1
|
||||||
|
break
|
||||||
|
print(nice)
|
||||||
|
|
1000
2015/day 5/P2/input.txt
Normal file
1000
2015/day 5/P2/input.txt
Normal file
File diff suppressed because it is too large
Load diff
15
2015/day 5/P2/string.py
Normal file
15
2015/day 5/P2/string.py
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
strings = open("input.txt").read().split("\n")[:-1]
|
||||||
|
nice = 0
|
||||||
|
for i in strings:
|
||||||
|
double = False
|
||||||
|
for j in range(len(i)-1):
|
||||||
|
if i.count(f"{i[j]}{i[j+1]}") >= 2 and f"{i[j]}{i[j]}{i[j]}" not in i:
|
||||||
|
double = True
|
||||||
|
break
|
||||||
|
for j in range(len(i)):
|
||||||
|
f2 = i.find(i[j], j+1)
|
||||||
|
if f2-j == 2 and double:
|
||||||
|
nice+=1
|
||||||
|
break
|
||||||
|
print(nice)
|
||||||
|
|
Loading…
Reference in a new issue