diff --git a/2024/full/day04.txt b/2024/full/day04.txt new file mode 100644 index 0000000..34e67d9 --- /dev/null +++ b/2024/full/day04.txt @@ -0,0 +1,140 @@ +MMASXSSXSAMXSMMMMSMMXXSXMASAMXSMMSAMXSSSMMMXAAXMASMSMSMXSSSSMSMSMMSMSMASMSAMXXSMMXAMXXXXMMSSSXMSSMSSXMASMMSSSMSMXMXMAXMAMXXXXSXSSMMSSMXASMXM +XXAMXAXAXXMAMAASXMXSAXXAXXMASAMXMMAMAMXAAAAASMXSMAAAAAXSMAMXAAXAAXXAAAXMXSMAXMAMXASMMSMSAAAXMAMMAAASMXMXAMAMAAAMASAMXMASMSSMMMAMAASAMXSSSMMS +MMXSAMMMMSMASXMSAAAMMMSMMXMAMASMMSSMMSSSMMSMXAASMMAMMMMXMAMMSMSSSMMSMSMSAMXXSMASMAMSAAASMMMXXAMSMMMMXAMMMMASMSMSASASXMAMAAAAMMSMSMMAMXMASAAA +XMAMAXMAAXXASAAXMMMSMAXMAXMASXMAXAXAXMAMXAXMMMMMAXMXMSASAASAAAXMAXMASAAMMSSMMMAMMAMAMMMMSMMASMMSAMXXSXSAXXMSAAAMAXAMXSMMMMSXSAMAAXMAMMMXMMMS +MMSXSMSMSSMSSMMMSSMAMASASXMAXAMSMASXMMMMMMAXMXMSXMXAMXAAAMMXSXMSXMSMSMSMAAMAAMAXMXSMMMXAASMAXMASMSMXMASXSMASMMSMXMAMASAXSXAAMASMMMMMXAMAXXAX +MAXXMAMSAXMASAAAAASXSASAMAMSXSXAAMXMXSAAASMSMAMMMSSMSMXMMMXAMAXMMASASAMMMMMSMXMMMXXXMMMSMSMSSMMMAXMASMMAMMAMAXMASMXMASAMXMMMMAMXXMASXSSMSMSS +MAMAMMMMMSMASMMMXXAXMXMAXSXXAXMASMAMMAMSXSAAXAXAAXAMAMXXSXMASMMAXXMMMAMXAMXMSAAASMMMSXMAMXAAMMXMMMMAMXMAMMASXMMASXAMMMXMXXAXMASXSSMSAASAAAAX +MXSMMM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XXMASXMXMSXSXMAMXSXMAMMMMMMMMMMSXAMAMAAMAMAAMMMMSMXSAXXAMXSAXXAAXMAS +SSXSAAASAMAAMXAAMMSSXMASMAAMSSSMSSXMSMAMSAMXSMMMAMMSMMXAMAMXAAAMMXAMAMMMSMSASMAAMSAMMMSAMXMSXXAAAAAXAAAMMSSMMMSASMMXSAMXMAMAMMMSAMXAAMMMXSAM +AAAMMMSMAMMXMMMMSAXMASAAMXMAAAAXAMXAASAMSAMXMXASAMAAASXSMSASMMSMASXSASAAAXMASMSAMXAMAAMAMXMASMSSSSSSMMXSAMSXAXMMMAAASXSAAAXAMXXMASMSMXMSAMXS +MMMMXMAXAMXXMASMMXMXMAMSAMXXMSMMMAMSMSSMSXMSMSXSXSSSSMAXXAMXMXXXMAMMXSMSSSMMMAMXSSXMMSSSMSMASXXXXMAAXAAMXMXMASXXSMMMSXSASASXSXAMSAAAXSXMASMA diff --git a/2024/python/day04.py b/2024/python/day04.py new file mode 100644 index 0000000..9807974 --- /dev/null +++ b/2024/python/day04.py @@ -0,0 +1,39 @@ +import matrix +import shared +from collections import Counter + +# XMAS = ['X','M','A','S'] +XMAS = "XMAS" + + +# @shared.profile +def part1(mx): + count = 0 + for idr, row in enumerate(mx): + for idc, c in enumerate(row): + los = matrix.line_of_sight(mx, idr, idc, distance=4, diagonals=True) + words = list(map("".join, los.values())) + counter = Counter(words) + count += counter[XMAS] + print(count) + + +# @shared.profile +def part2(rows): + pass + + +def main(): + mx = matrix.load_matrix_file(shared.get_fname(4), str) + with shared.elapsed_timer() as elapsed: + part1(mx) + print("🕒", elapsed()) + + rows = [row for row in shared.load_rows(4, True)] + with shared.elapsed_timer() as elapsed: + part2(rows) + print("🕒", elapsed()) + + +if __name__ == "__main__": + main() diff --git a/2024/python/matrix.py b/2024/python/matrix.py index 4b5125f..b43852b 100644 --- a/2024/python/matrix.py +++ b/2024/python/matrix.py @@ -186,6 +186,7 @@ def get_neighbor_coords(matrix, c, r, diagonals=True): pass # okay we out of bounds boizzzz return neighbors + def get_neighbors_cardinal(matrix, c, r, diagonals=True): height = len(matrix) width = len(matrix[0]) @@ -199,14 +200,17 @@ def get_neighbors_cardinal(matrix, c, r, diagonals=True): try: value = matrix[r + _r][c + _c] # Try to get a value error if r + _r >= 0 and c + _c >= 0: - neighbors[CARDINALS[coord]] = {"c": c + _c, "r": r + _r, "value":value} # woo, no error, this coord is valid + neighbors[CARDINALS[coord]] = { + "c": c + _c, + "r": r + _r, + "value": value, + } # woo, no error, this coord is valid except IndexError: pass # okay we out of bounds boizzzz return neighbors - -def line_of_sight_coords( +def line_of_sight_coords_diagonals( matrix, row, col, distance=None ) -> Dict[str, List[Tuple[int, int]]]: """ @@ -221,37 +225,112 @@ def line_of_sight_coords( col_ids = list(range(0, height)) row_ids = list(range(0, width)) + directions = { + "UR": [], + "UL": [], + "DR": [], + "DL": [] + } + ur = False + ul = False + dl = False + dr = False + + # Boundaries of the grid + max_row, max_col = height, width + + # Up-right (decrease row, increase column) + r, c = row, col + while r > 0 and c < max_col - 1: + ur = True + r -= 1 + c += 1 + directions["UR"].append((r, c)) + + # Up-left (decrease row, decrease column) + r, c = row, col + while r > 0 and c > 0: + ul = True + r -= 1 + c -= 1 + directions["UL"].append((r, c)) + + # Down-right (increase row, increase column) + r, c = row, col + while r < max_row - 1 and c < max_col - 1: + dr = True + r += 1 + c += 1 + directions["DR"].append((r, c)) + + # Down-left (increase row, decrease column) + r, c = row, col + while r < max_row - 1 and c > 0: + dl = True + r += 1 + c -= 1 + directions["DL"].append((r, c)) + if distance: - up_ids, down_ids = ( - list(reversed(col_ids[:col])), - col_ids[col + 1 : col + distance + 1], - ) - left_ids, right_ids = ( - list(reversed(row_ids[:row])), - row_ids[row + 1 : row + distance + 1], - ) + for _dir in ["DL", "UL", "DR", "UR"]: + directions[_dir] = directions[_dir][:distance - 1] + if directions[_dir]: + directions[_dir].insert(0, (row,col)) + return directions + + +def line_of_sight_coords( + matrix, row, col, distance=None, diagonals=False +) -> Dict[str, List[Tuple[int, int]]]: + """ + Takes a matrix, a row, and a column + calculates the coordinates to the edge for all four cardinal directions + + returns a dict with a list of tuple coordes TRAVELING AWAY from the + requested coordinate + """ + height, width = get_size(matrix) + + col_ids = list(range(0, height)) + row_ids = list(range(0, width)) + + up_ids = list(reversed(col_ids[:col])) + down_ids = col_ids[col + 1 :] + left_ids = list(reversed(row_ids[:row])) + right_ids = row_ids[row + 1 :] + + if distance: + left = [(r, col) for r in left_ids[:distance - 1]] + right = [(r, col) for r in right_ids[:distance - 1]] + up = [(row, c) for c in up_ids[:distance - 1]] + down = [(row, c) for c in down_ids[:distance - 1]] + left.insert(0, (row, col)) + right.insert(0, (row, col)) + down.insert(0, (row, col)) + up.insert(0, (row, col)) else: - up_ids, down_ids = list(reversed(col_ids[:col])), col_ids[col + 1 :] - left_ids, right_ids = list(reversed(row_ids[:row])), row_ids[row + 1 :] + left = [(r, col) for r in left_ids] + right = [(r, col) for r in right_ids] + up = [(row, c) for c in up_ids] + down = [(row, c) for c in down_ids] - left = [(r, col) for r in left_ids] - right = [(r, col) for r in right_ids] - up = [(row, c) for c in up_ids] - down = [(row, c) for c in down_ids] - - return { + directions = { "U": up, "L": left, "D": down, "R": right, } + if diagonals: + vals = line_of_sight_coords_diagonals(matrix, row, col, distance) + directions.update(vals) + return directions -def line_of_sight(mx, row, col, distance=None): +def line_of_sight(mx, row, col, distance=None, diagonals=False): """ renders a line of sight coord calculation, into the values """ - coords = line_of_sight_coords(mx, row, col, distance) + coords = line_of_sight_coords(mx, row, col, distance, diagonals) los = defaultdict(list) for k, ids in coords.items(): for _row, _col in ids: diff --git a/2024/samples/day04.txt b/2024/samples/day04.txt new file mode 100644 index 0000000..1f4eda2 --- /dev/null +++ b/2024/samples/day04.txt @@ -0,0 +1,10 @@ +MMMSXXMASM +MSAMXMSMSA +AMXSXMAAMM +MSAMASMSMX +XMASAMXAMM +XXAMMXXAMA +SMSMSASXSS +SAXAMASAAA +MAMMMXMMMM +MXMXAXMASX