Content-Length: 324516 | pFad | http://github.com/Piratmac/adventofcode-python/commit/619c8523bb1ba054882cb5771eeb3403f2910f3a

73 Fixed issue in dot library + added border identification to grid · Piratmac/adventofcode-python@619c852 · GitHub
Skip to content

Commit 619c852

Browse files
committed
Fixed issue in dot library + added border identification to grid
1 parent b38c2a2 commit 619c852

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

2021/dot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def manhattan_distance(self, reference=0):
171171
def set_terrain(self, terrain):
172172
self.terrain = terrain or self.terrain_default
173173
self.is_walkable, self.is_waypoint = self.terrain_map.get(
174-
terrain, self.terrain_map[self.terrain_default]
174+
self.terrain, self.terrain_map[self.terrain_default]
175175
)
176176

177177
def set_directions(self):

2021/grid.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -255,20 +255,16 @@ def get_borders(self):
255255
min_y, max_y = int(min(y_vals)), int(max(y_vals))
256256

257257
borders = []
258-
borders.append([x + 1j * max_y for x in sorted(x_vals)])
259-
borders.append([max_x + 1j * y for y in sorted(y_vals)])
260-
borders.append([x + 1j * min_y for x in sorted(x_vals)])
261-
borders.append([min_x + 1j * y for y in sorted(y_vals)])
258+
borders.append([self.dots[x + 1j * max_y] for x in sorted(x_vals)])
259+
borders.append([self.dots[max_x + 1j * y] for y in sorted(y_vals)])
260+
borders.append([self.dots[x + 1j * min_y] for x in sorted(x_vals)])
261+
borders.append([self.dots[min_x + 1j * y] for y in sorted(y_vals)])
262262

263263
borders_text = []
264264
for border in borders:
265-
borders_text.append(
266-
Grid({pos: self.dots[pos].terrain for pos in border})
267-
.dots_to_text()
268-
.replace("\n", "")
269-
)
265+
borders_text.append("".join(dot.terrain for dot in border))
270266

271-
return borders_text
267+
return borders, borders_text
272268

273269
def get_columns(self):
274270
"""

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/Piratmac/adventofcode-python/commit/619c8523bb1ba054882cb5771eeb3403f2910f3a

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy