Skip to content

Commit

Permalink
[2024/4] add verbose output
Browse files Browse the repository at this point in the history
  • Loading branch information
StarlitGhost committed Dec 8, 2024
1 parent f5ebfe2 commit acd5342
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions 2024/4/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
def search_xmas(grid: Grid, pos: Vec2) -> int:
xmas_count = 0
for dir_ in [Dir.E, Dir.SE, Dir.S, Dir.SW, Dir.W, Dir.NW, Dir.N, Dir.NE]:
word = [grid[pos + Vec2(dir_) * i]
for i in range(4) if grid.in_bounds(pos + Vec2(dir_) * i)]
letter_positions = [pos + Vec2(dir_) * i
for i in range(4)
if grid.in_bounds(pos + Vec2(dir_) * i)]
word = [grid[letter_pos] for letter_pos in letter_positions]
if word == list('XMAS'):
xmas_count += 1
# print(pos, dir_, word)
if aoc.args().verbose:
print(f"{pos} {dir_} {word}")
return xmas_count


Expand Down

0 comments on commit acd5342

Please sign in to comment.