giving up
This commit is contained in:
parent
5e8b272801
commit
a172a101ab
@ -108,6 +108,7 @@ def part2(rows):
|
|||||||
print("possible:", possible_count)
|
print("possible:", possible_count)
|
||||||
print(maxZ,maxY,maxX)
|
print(maxZ,maxY,maxX)
|
||||||
print()
|
print()
|
||||||
|
#shared.render_cubes(maxX+2,maxY+2,maxZ+1, [x for x in _cubes])
|
||||||
|
|
||||||
air_nx = {}
|
air_nx = {}
|
||||||
for a in air:
|
for a in air:
|
||||||
@ -119,51 +120,63 @@ def part2(rows):
|
|||||||
|
|
||||||
# loop row by row
|
# loop row by row
|
||||||
inside = []
|
inside = []
|
||||||
for z in range(0,maxZ+1):
|
for z in range(0,maxZ+2):
|
||||||
seen = set()
|
seen = set()
|
||||||
seen.add((0,0,z))
|
seen.add((0,0,z))
|
||||||
for y in range(0,maxY+1):
|
mx = matrix.matrix_of_size(maxX+2,maxY+2)
|
||||||
for x in range(0,maxX+1):
|
|
||||||
xyz = (x,y,z)
|
for x,y in matrix.spiral_generator(maxX+2, maxY+2):
|
||||||
if xyz in _cubes:
|
xyz = x,y,z
|
||||||
#print(xyz,'is cube')
|
mx[y][x] = "#"
|
||||||
continue
|
if xyz in _cubes:
|
||||||
ns = get_flat_neighbors_from(x,y,z, air)
|
continue
|
||||||
for neigh in ns:
|
ns = get_flat_neighbors(x,y,z)
|
||||||
if neigh in seen and neigh not in _cubes:
|
for neigh in ns:
|
||||||
seen.add(xyz)
|
if neigh in seen:
|
||||||
this_level = air_in_row(air, z)
|
seen.add(xyz)
|
||||||
print(this_level, seen)
|
|
||||||
print(len(this_level), len(seen))
|
this_level = set(x for x in air_in_row(air, z))
|
||||||
inside.extend([x for x in this_level if x not in seen])
|
for (x,y,z) in seen:
|
||||||
#print()
|
mx[y][x] = 0
|
||||||
#print(inside)
|
|
||||||
#print()
|
for x,y,z in this_level:
|
||||||
actually_inside = []
|
if (x,y,z) not in seen:
|
||||||
for i in inside:
|
mx[y][x] = "o"
|
||||||
ns = get_neighbors(*i)
|
print(matrix.ppmx(mx, pad=False,space=False))
|
||||||
# check for surrounded 100% by rock
|
print()
|
||||||
rock_count = 0
|
|
||||||
for n in ns:
|
#print(len(this_level), len(seen))
|
||||||
if n in _cubes:
|
#inside.extend([x for x in this_level if x not in seen])
|
||||||
rock_count +=1
|
#print(seen)
|
||||||
if rock_count == 6:
|
#shared.render_cubes(maxX+2,maxY+2,maxZ+1, [x for x in seen])
|
||||||
print("in rock")
|
#shared.render_cubes(maxX+2,maxY+2,maxZ+1, [x for x in this_level-seen])
|
||||||
actually_inside.append(i)
|
##print()
|
||||||
continue
|
##print(inside)
|
||||||
#check for surrounded 100% by air
|
##print()
|
||||||
air_count = 0
|
#actually_inside = []
|
||||||
for n in ns:
|
#for i in inside:
|
||||||
if n in air:
|
# ns = get_neighbors(*i)
|
||||||
air_count +=1
|
# # check for surrounded 100% by rock
|
||||||
print("in air")
|
# rock_count = 0
|
||||||
break
|
# for n in ns:
|
||||||
actually_inside.append(i)
|
# if n in _cubes:
|
||||||
#print(actually_inside)
|
# rock_count +=1
|
||||||
tot, _, _, _, _, _ = surface_area(actually_inside)
|
# if rock_count == 6:
|
||||||
print(tot)
|
# print("in rock")
|
||||||
print(potential - tot)
|
# actually_inside.append(i)
|
||||||
shared.render_cubes(maxX,maxY,maxZ, [x for x in actually_inside])
|
# continue
|
||||||
|
# #check for surrounded 100% by air
|
||||||
|
# air_count = 0
|
||||||
|
# for n in ns:
|
||||||
|
# if n in air:
|
||||||
|
# air_count +=1
|
||||||
|
# print("in air")
|
||||||
|
# break
|
||||||
|
# actually_inside.append(i)
|
||||||
|
##print(actually_inside)
|
||||||
|
#tot, _, _, _, _, _ = surface_area(actually_inside)
|
||||||
|
#print(tot)
|
||||||
|
#print(potential - tot)
|
||||||
|
|
||||||
def air_in_row(air, z):
|
def air_in_row(air, z):
|
||||||
x = []
|
x = []
|
||||||
|
@ -373,3 +373,53 @@ def out_of_bounds(mx, row, col, shape=None):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def spiral_generator(width, height):
|
||||||
|
k = 0
|
||||||
|
l = 0
|
||||||
|
m = height
|
||||||
|
n = width
|
||||||
|
|
||||||
|
''' k - starting row index
|
||||||
|
m - ending row index
|
||||||
|
l - starting column index
|
||||||
|
n - ending column index
|
||||||
|
i - iterator '''
|
||||||
|
|
||||||
|
while (k < m and l < n):
|
||||||
|
|
||||||
|
# Print the first row from
|
||||||
|
# the remaining rows
|
||||||
|
for i in range(l, n):
|
||||||
|
yield (i,k)
|
||||||
|
#print(a[k][i], end=" ")
|
||||||
|
|
||||||
|
k += 1
|
||||||
|
|
||||||
|
# Print the last column from
|
||||||
|
# the remaining columns
|
||||||
|
for i in range(k, m):
|
||||||
|
yield (n-1,i)
|
||||||
|
#print(a[i][n - 1], end=" ")
|
||||||
|
|
||||||
|
n -= 1
|
||||||
|
|
||||||
|
# Print the last row from
|
||||||
|
# the remaining rows
|
||||||
|
if (k < m):
|
||||||
|
|
||||||
|
for i in range(n - 1, (l - 1), -1):
|
||||||
|
#print(a[m - 1][i], end=" ")
|
||||||
|
yield (i, m-1)
|
||||||
|
|
||||||
|
m -= 1
|
||||||
|
|
||||||
|
# Print the first column from
|
||||||
|
# the remaining columns
|
||||||
|
if (l < n):
|
||||||
|
for i in range(m - 1, k - 1, -1):
|
||||||
|
#print(a[i][l], end=" ")
|
||||||
|
yield (l,i)
|
||||||
|
|
||||||
|
l += 1
|
||||||
|
|
||||||
|
50
2022/samples/day18-alt.txt
Normal file
50
2022/samples/day18-alt.txt
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
1,1,1
|
||||||
|
2,1,1
|
||||||
|
3,1,1
|
||||||
|
4,1,1
|
||||||
|
5,1,1
|
||||||
|
6,1,1
|
||||||
|
1,2,1
|
||||||
|
2,2,1
|
||||||
|
3,2,1
|
||||||
|
4,2,1
|
||||||
|
5,2,1
|
||||||
|
6,2,1
|
||||||
|
1,3,1
|
||||||
|
2,3,1
|
||||||
|
3,3,1
|
||||||
|
4,3,1
|
||||||
|
5,3,1
|
||||||
|
6,3,1
|
||||||
|
1,1,2
|
||||||
|
2,1,2
|
||||||
|
3,1,2
|
||||||
|
4,1,2
|
||||||
|
5,1,2
|
||||||
|
6,1,2
|
||||||
|
1,2,2
|
||||||
|
6,2,2
|
||||||
|
1,3,2
|
||||||
|
2,3,2
|
||||||
|
3,3,2
|
||||||
|
4,3,2
|
||||||
|
5,3,2
|
||||||
|
6,3,2
|
||||||
|
1,1,3
|
||||||
|
2,1,3
|
||||||
|
3,1,3
|
||||||
|
4,1,3
|
||||||
|
5,1,3
|
||||||
|
6,1,3
|
||||||
|
1,2,3
|
||||||
|
2,2,3
|
||||||
|
3,2,3
|
||||||
|
4,2,3
|
||||||
|
5,2,3
|
||||||
|
6,2,3
|
||||||
|
1,3,3
|
||||||
|
2,3,3
|
||||||
|
3,3,3
|
||||||
|
4,3,3
|
||||||
|
5,3,3
|
||||||
|
6,3,3
|
Loading…
Reference in New Issue
Block a user