From 0a5c1f77d01fc0bd166494787f24562e2fd3a9e9 Mon Sep 17 00:00:00 2001 From: Botond Hende Date: Wed, 11 Dec 2024 10:18:23 +0100 Subject: renamed day folders to two digit format --- 2024/day6/input | 130 --------------------------------------------------- 2024/day6/input_test | 10 ---- 2024/day6/solve.py | 55 ---------------------- 2024/day6/solve2.py | 78 ------------------------------- 4 files changed, 273 deletions(-) delete mode 100644 2024/day6/input delete mode 100644 2024/day6/input_test delete mode 100644 2024/day6/solve.py delete mode 100644 2024/day6/solve2.py (limited to '2024/day6') diff --git a/2024/day6/input b/2024/day6/input deleted file mode 100644 index f297efc..0000000 --- a/2024/day6/input +++ /dev/null @@ -1,130 +0,0 @@ -........#.............................#......#................#..................#..................#.........#.#.#............... -...........................................#..#......................#............................#...........................#.#. -.............#..........#........#.#...........#........................#............................##........................... -............#.............#.....................................#........................#.....#.................................. -.........#...........#................#................................#......#.....................#.............#..............# -...........................##...........................................................................................#......... -...........#.......#.................................................................#..............#....................#........ -.......................#.............................................#.........................................#.#..............#. -.#...................#..................#...........#...#.........#...##.......................................................... -.................#..........#.....#.........#.....................................................................#..........##... -....#.#............#..........#.......................#.........................#.................#.........#.............#....#.. -...#....................................#.............#..............................#............#.....................#........# -....................#..............................#...#.#...#.#..........#.................................#..................#.. -........................................................................................#.....#.........#............#.........#.. -...................#.................#.......................................................................................#...# -..............#.......#..................#........#....#........#.....................#..........................#................ -...........#..#....................................#.............#.#..#.......................................#.........#.#...#... -...#.............#............................#..............#....................#.#............................................. -..#...........#.#.........#...............................................#...#...............#.#...........#........##....#...... -.............................................#..#.........#......#................................................................ -.................................#.................#..............#.....#...................................................#..... -............................#.......#............#...............................................................#................ -.....#....................#...........................................#..........................#..........#..#...#......#...#... -........................#......#...#.......................#....##.......#..........#...............#............................. -#..#....................................................................................................#......................... -...........................................#......#..........................#..............................#.............#.....#. -..............#......................#..#...................................#.#..................#.......#............#........... -.................#...................................#..........#......#....#.#.#...#....................#..........#......#...... -........#....................................#........#.........................................#......#.#...............#......#. -..................................#......#........#........#.#......#.........................#.#.......#......................#.. -......#..#.........#............#...........................................................#.............#.........#............. -.........................#......................#.....#........#..........#....................................................... -#.......#..................#............................................................#......................................... -.........#.....#.............#...............#......#.....................#....................................................... -.........#..#.........................................................#.........##..................##........#................... -.#.....#..............#..............#.........................................#.....................................#............ -..............................#......................................................................................#............ -..............#..........................#................................#.#.....#...........#.........#......................... -....................#...#.#...........................................................................#...........#............... -...........#.............................#....................#........#...............................##....#.................... -.....................#......................#.#.....#...........................#.......#........#................................ -#..........#...............#.......#..................................#.....................................................##.... -.........................................................#...#....#...............................................#.........##.... -.....................#......................#..............#..................................................#................... -......#.............#........#..................................................#...#.............................#......#........ -....................#............#........#...............#......#.......#........................................................ -..........................................................................#........................#......#.............#.......#. -.....................................................#..#........#....................#.....................#..................... -..#.................#........................................#................................................##...............#.. -.............#......#.........#................................................................................#.................. -#......#.......................................................................................................#......#........... -.......##.......................#...................#.........##..........#.............................#........................# -...........................................................#................................#...............#............##....... -..........................#...................#...........................................................#.............#........# -...#......................#..##................................................................................................#.. -............#..#.........#...#.........................................................#........#..............#.................. -.................#.................#........#............................................................................#........ -............#..#..#..#....#...........................#.................................................#..#...................#.. -....................................................#..#.................................#.#..............................#....... -.........#.#................................................#..#............................................................#..... -...##............................................#.....#.#...........................#....#.................#.#..........#........ -...............#.#.#.........................................#......#.....#..............................................#....#... -.............#........................................#....#.......................................#...#....#..................... -...........#.................................#...............................................#...........#..#..#......#........... -#.......................................###....#....#.........................................#......#.............#.............. -...............#.#.....................................................................................#....................#..... -##.........#..............#................................#..#..#..........#....................#..#..........#.....#............ -...................#..........................................#........................#.......................................#.. -#........#.#.....#............................................................##......#....#...........................#.......... -...............##....#.............#......................................#......................#...................#.#.......... -....................................##....#.............................................#..........#...................#....#..... -.....#...............#........#..............#.............#..#..#...#.................................................#.#...##... -........##.....................................................#.................................................................. -.........#.............................................................#.......................................................... -.............#.............#............................................................................#....#..........#.......#. -.#........#...........................................#....#.........#......#............#.#................................#....# -...............................................#.......#.............#.............#....................#.....................#... -......................................#....................................................#...................................#.. -....#........#.....................................................#.......................................##..................... -..........................................#............................................#.......#.....................#...#........ -................#.#.............#.....#....................#............#.............................................#........... -..............................#..............#.................#...................#...#.......#.................................. -.#...............................................................#..................#......#............#................#........ -...................................#.................................##........................................................... -...............................................................#....#..##...................#..#..............................#... -..............................#...........#.................................................#.#....#...............#.....#........ -............................#........#.........#.........................................#....#................................... -........................#................................................#....#..............#.........................#.......... -.........#....#....................#.......................#.#.......................................................#............ -.........................#......................................................#................................................. -.............#...#...........#...................#.#..............^........................................#....#................. -.................##............................................................................................................... -..................#......#..............................#...............#.##.........................#............................ -....................................................###........................................................................... -........#....................................................#........#........................................##...#.......#..... -.........................##.....#.........................................................................#.........#............. -.................#...........................................................................#........#..............#..#......... -.........#.#..................................#..#...................................#.................................#.......... -.....#............#...#............#..............................#..........#.........#....#...........#......................... -#...#...........................................................................................#.....#....#.........#.....#...... -......................................................#.#...............#......#.................#...............#.............#.. -.......................................................................................#.........#...#...........#..............#. -.........................#................#.................#...............................#........#.##....................#.... -.....#...#................................#......................#...........#........................................#..#........ -.................#................................#.#.....................#............................................#....#..... -...................#............................................................................#........#.....................##. -.....#.................................................................#..................#........#.......#...#.................. -...............................#..#...................................#..........#...........#......................#............. -....#................#..................#..........................................................................#........#..... -......#.........................#............................................#....................#....#.......................... -.#.......#....#.#...#....#................#........................#...................#...................#......#............... -..#...................#......#.#........#.........................#.........................#............#........................ -..#....#...#.......................................................................#......................#....................#.. -.......#...#............................................................#.................#......................................# -..##..........#..................#...............#.....#..#...........#....#...............................................#...... -...##....#............##..................................................................................................#....... -...........#.........................#....#......#...#.............................................#....................#........# -............................................................................#...............#..#..............#................... -.....#............................#.....................................................................................#......#.# -.........#.............................#.....#.........................................................#.#.....#.................. -.......................#..#.#.......#..#................................#.....#..............#.........................#.......... -.................#.....................#............................................................................#........#.... -........#...............................................................#....#........#.........#.......#......#......#........... -..............#............#......#..............#.#...........#.............................##...##.#..............#.....#....... -##....................................................................#.......................#.................#................. -............#...................................................................................................................#. -...#....#....................#..............................................................................#........#............ -....#......................#......................................................#............................................... -.#...#...........#....#........#...#.................#..............................#................#.##......................... -...#.................#..............................#................................#...........#................................ \ No newline at end of file diff --git a/2024/day6/input_test b/2024/day6/input_test deleted file mode 100644 index f76349a..0000000 --- a/2024/day6/input_test +++ /dev/null @@ -1,10 +0,0 @@ -....#..... -.........# -.......... -..#....... -.......#.. -.......... -.#..^..... -........#. -#......... -......#... \ No newline at end of file diff --git a/2024/day6/solve.py b/2024/day6/solve.py deleted file mode 100644 index 7e8a972..0000000 --- a/2024/day6/solve.py +++ /dev/null @@ -1,55 +0,0 @@ -import sys - -lines = [] -with open("input") as f: - for line in f.readlines(): - lines.append(list(line.strip())) - -found_guard = False -guard_row_idx = None -guard_col_idx = None -direction = None - -directions = [(-1, 0), (0, 1), (1, 0), (0, -1)] - -for line_idx, line in enumerate(lines): - for icon_idx, guard_icon in enumerate(("^", ">", "v", "<")): - if guard_icon in line: - guard_row_idx = line_idx - guard_col_idx = line.index(guard_icon) - direction = directions[icon_idx] - found_guard = True - break - - if found_guard: - break - -if not found_guard: - sys.exit("Could not found guard.") - -row_count = len(lines) -col_count = len(lines[0]) -while True: - lines[guard_row_idx][guard_col_idx] = "X" - new_row_idx = guard_row_idx + direction[0] - new_col_idx = guard_col_idx + direction[1] - - if new_row_idx < 0 or new_row_idx >= row_count or new_col_idx < 0 or new_col_idx >= col_count: - break - - if lines[new_row_idx][new_col_idx] == "#": - dir_idx = directions.index(direction) - if dir_idx == len(directions) - 1: - dir_idx = 0 - else: - dir_idx += 1 - direction = directions[dir_idx] - else: - guard_row_idx = new_row_idx - guard_col_idx = new_col_idx - -count = 0 -for line in lines: - count += line.count("X") - -print(count) diff --git a/2024/day6/solve2.py b/2024/day6/solve2.py deleted file mode 100644 index faaf88a..0000000 --- a/2024/day6/solve2.py +++ /dev/null @@ -1,78 +0,0 @@ -import sys - -def traverse(room: list[list[str]], guard_current_row: int, guard_current_col: int, direct: tuple[int, int], check_for_loop: bool) -> bool: - row_count = len(room) - col_count = len(room[0]) - previous_directions: list[list[list[tuple[int, int]]]] = [] - for _ in range(row_count): - previous_directions.append([]) - for _ in range(col_count): - previous_directions[-1].append([]) - - while True: - if not check_for_loop: - room[guard_current_row][guard_current_col] = "X" - else: - if direct in previous_directions[guard_current_row][guard_current_col]: - return True - - previous_directions[guard_current_row][guard_current_col].append(direct) - - new_row_idx = guard_current_row + direct[0] - new_col_idx = guard_current_col + direct[1] - - if new_row_idx < 0 or new_row_idx >= row_count or new_col_idx < 0 or new_col_idx >= col_count: - break - - if room[new_row_idx][new_col_idx] == "#": - dir_idx = directions.index(direct) - if dir_idx == len(directions) - 1: - dir_idx = 0 - else: - dir_idx += 1 - direct = directions[dir_idx] - else: - guard_current_row = new_row_idx - guard_current_col = new_col_idx - - return False - -lines = [] -with open("input") as f: - for line in f.readlines(): - lines.append(list(line.strip())) - -found_guard = False -guard_row_idx = None -guard_col_idx = None -direction = None - -directions = [(-1, 0), (0, 1), (1, 0), (0, -1)] - -for line_idx, line in enumerate(lines): - for icon_idx, guard_icon in enumerate(("^", ">", "v", "<")): - if guard_icon in line: - guard_row_idx = line_idx - guard_col_idx = line.index(guard_icon) - direction = directions[icon_idx] - found_guard = True - break - - if found_guard: - break - -if not found_guard: - sys.exit("Could not found guard.") - -traverse(lines, guard_row_idx, guard_col_idx, direction, False) - -count = 0 -for row_idx, line in enumerate(lines): - for col_idx, char in enumerate(line): - if char == "X": - lines[row_idx][col_idx] = "#" - if traverse(lines, guard_row_idx, guard_col_idx, direction, True): - count += 1 - lines[row_idx][col_idx] = "X" - -print(count) -- cgit v1.2.3-70-g09d2