Skip to content

Commit 42d72f1

Browse files
committed
Finished 11
1 parent 1d5ae61 commit 42d72f1

5 files changed

+203
-0
lines changed

Day11imput.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
6617113584
2+
6544218638
3+
5457331488
4+
1135675587
5+
1221353216
6+
1811124378
7+
1387864368
8+
4427637262
9+
6778645486
10+
3682146745

Day11puzzle1.py

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
data = open("E:\CodingStuff\AdventOfCode\Day11imput.txt")
2+
data = data.readlines()
3+
for row in range(len(data)):
4+
data[row] = data[row].strip("\n")
5+
data = [list(x) for x in data]
6+
data = [[int(c) for c in x] for x in data]
7+
print(len(data))
8+
print(len(data[0]))
9+
10+
class octgrid:
11+
def __init__(self, data):
12+
self.data=data
13+
self.count=0
14+
15+
def day(self):
16+
self.flashlist = []
17+
for row in range(len(self.data)):
18+
for col in range(len(self.data[0])):
19+
self.data[row][col]+=1
20+
21+
for row in range(len(self.data)):
22+
for col in range(len(self.data[0])):
23+
if(self.data[row][col]>9 and (not ([row,col] in self.flashlist))):
24+
self.flash(row, col)
25+
for row in range(len(self.data)):
26+
for col in range(len(self.data[0])):
27+
if([row,col] in self.flashlist):
28+
self.data[row][col] = 0
29+
return(len(self.flashlist))
30+
31+
32+
33+
34+
35+
def flash(self, row, col):
36+
self.count+=1
37+
self.flashlist.append([row,col])
38+
for x in range(-1,2):
39+
for y in range(-1,2):
40+
file = row+x
41+
colunm = col+y
42+
if((file<len(self.data) and file>-1)):
43+
if((colunm<len(self.data[0]) and (colunm)>-1)):
44+
self.data[file][colunm]+=1
45+
if((not ([file,colunm] in self.flashlist)) and self.data[file][colunm]>9):
46+
self.flash(file, colunm)
47+
48+
grid = octgrid(data)
49+
b=0
50+
for count in range(100):
51+
b+=grid.day()
52+
print(grid.count)
53+
54+

Day11puzzle2.py

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
data = open("E:\CodingStuff\AdventOfCode\Day11imput.txt")
2+
data = data.readlines()
3+
for row in range(len(data)):
4+
data[row] = data[row].strip("\n")
5+
data = [list(x) for x in data]
6+
data = [[int(c) for c in x] for x in data]
7+
print(len(data))
8+
print(len(data[0]))
9+
10+
class octgrid:
11+
def __init__(self, data):
12+
self.data=data
13+
self.count=0
14+
15+
def day(self):
16+
self.flashlist = []
17+
for row in range(len(self.data)):
18+
for col in range(len(self.data[0])):
19+
self.data[row][col]+=1
20+
21+
for row in range(len(self.data)):
22+
for col in range(len(self.data[0])):
23+
if(self.data[row][col]>9 and (not ([row,col] in self.flashlist))):
24+
self.flash(row, col)
25+
for row in range(len(self.data)):
26+
for col in range(len(self.data[0])):
27+
if([row,col] in self.flashlist):
28+
self.data[row][col] = 0
29+
return(len(self.flashlist))
30+
31+
32+
33+
34+
35+
def flash(self, row, col):
36+
self.count+=1
37+
self.flashlist.append([row,col])
38+
for x in range(-1,2):
39+
for y in range(-1,2):
40+
file = row+x
41+
colunm = col+y
42+
if((file<len(self.data) and file>-1)):
43+
if((colunm<len(self.data[0]) and (colunm)>-1)):
44+
self.data[file][colunm]+=1
45+
if((not ([file,colunm] in self.flashlist)) and self.data[file][colunm]>9):
46+
self.flash(file, colunm)
47+
48+
grid = octgrid(data)
49+
b=0
50+
cheese=True
51+
while cheese:
52+
b+=1
53+
if(grid.day()==100):
54+
cheese=False
55+
print(b)
56+
57+
58+

Day12imput.txt

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
fw-ll
2+
end-dy
3+
tx-fw
4+
tx-tr
5+
dy-jb
6+
ZD-dy
7+
dy-BL
8+
dy-tr
9+
dy-KX
10+
KX-start
11+
KX-tx
12+
fw-ZD
13+
tr-end
14+
fw-jb
15+
fw-yi
16+
ZD-nr
17+
start-fw
18+
tx-ll
19+
ll-jb
20+
yi-jb
21+
yi-ll
22+
yi-start
23+
ZD-end
24+
ZD-jb
25+
tx-ZD

Day12puzzle1.py

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
data = open("E:\CodingStuff\AdventOfCode\Day12imput.txt")
2+
data = data.readlines()
3+
data = [x.strip("\n").split("-") for x in data]
4+
5+
class cave:
6+
def __init__(self, letter, data):
7+
self.id = letter
8+
self.connections = []
9+
for row in data:
10+
11+
if(row[0]==self.id):
12+
self.connections.append(row[1])
13+
if(row[1]==self.id):
14+
self.connections.append(row[0])
15+
self.big=False
16+
if (self.id==self.id.upper()):
17+
self.big=True
18+
19+
cavedict = {}
20+
caveidlist = []
21+
for row in data:
22+
for col in row:
23+
if col not in caveidlist:
24+
caveidlist.append(col)
25+
cavedict[col] = cave(col, data)
26+
smallcavelist = []
27+
for row in caveidlist:
28+
if not cavedict[row].big:
29+
smallcavelist[row] = row
30+
31+
32+
33+
class paths:
34+
def __init__(self, cavedict):
35+
self.cavelist = cavedict
36+
self.optionslist = []
37+
self.path = [cavedict["start"]]
38+
39+
def genpath(self):
40+
self.optionslist.append(len(cavedict["start"].connections)-1)
41+
restricted = []
42+
while True:
43+
if(cavedict[self.path[-1].connections[self.optionslist[-1]]] not in (restricted)):
44+
self.path.append(cavedict[self.path[-1].connections[self.optionslist[-1]]])
45+
if not self.path[-1].big:
46+
restricted.append(self.path[-1])
47+
if(self.path[-1].id == "end"):
48+
return self.path
49+
self.optionslist.append
50+
51+
52+
53+
54+
55+
56+

0 commit comments

Comments
 (0)