From 4174f627fcd3df6ea42b675d25f529363a5d23af Mon Sep 17 00:00:00 2001 From: kleph Date: Mon, 8 Dec 2025 15:05:39 +0100 Subject: [PATCH] 2025 - Day 7 part 1 --- 2025/7/7.py | 35 ++++++++++ 2025/7/input.txt | 142 +++++++++++++++++++++++++++++++++++++++ 2025/7/input_example.txt | 16 +++++ 3 files changed, 193 insertions(+) create mode 100644 2025/7/7.py create mode 100644 2025/7/input.txt create mode 100644 2025/7/input_example.txt diff --git a/2025/7/7.py b/2025/7/7.py new file mode 100644 index 0000000..78a0699 --- /dev/null +++ b/2025/7/7.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python +# 2025 - Advent Of Code 7 + +# file = 'input_example.txt' +file = 'input.txt' + +# pylint: disable=consider-using-with +grid = [line.strip('\n') for line in open(file, encoding="utf-8")] + +MAX_X = len(grid[0]) +MAX_Y = len(grid) + +for s in range(0, len(grid[0])): + if grid[0][s] == 'S': + start_pos = (s, 0) + break +print(f'{start_pos=}') + +beams = [start_pos] +split = 0 +for liney in range(1, MAX_Y-1): + new_beams = [] + for b in beams: + x = b[0] + y = b[1] + if grid[y+1][x] == '^': + new_beams.append((x-1, y+1)) + new_beams.append((x+1, y + 1)) + split += 1 + else: + new_beams.append((x, y + 1)) + print(f'end {liney}: {new_beams}') + beams = list(set(new_beams)) + +print(f'{split=}') \ No newline at end of file diff --git a/2025/7/input.txt b/2025/7/input.txt new file mode 100644 index 0000000..a2514f6 --- /dev/null +++ b/2025/7/input.txt @@ -0,0 +1,142 @@ +......................................................................S...................................................................... +............................................................................................................................................. +......................................................................^...................................................................... +............................................................................................................................................. +.....................................................................^.^..................................................................... +............................................................................................................................................. +....................................................................^...^.................................................................... +............................................................................................................................................. +...................................................................^.^.^.^................................................................... +............................................................................................................................................. +..................................................................^.^.....^.................................................................. +............................................................................................................................................. +.................................................................^.^.^.^.^.^................................................................. +............................................................................................................................................. +................................................................^.^.......^.^................................................................ +............................................................................................................................................. +...............................................................^.^.^...^.^.^.^............................................................... +............................................................................................................................................. +..............................................................^.^.^.^.^.^.^...^.............................................................. +............................................................................................................................................. +.............................................................^.^.^...^.......^.^............................................................. +............................................................................................................................................. +............................................................^.^.....^.^.^.^.^.^.^............................................................ +............................................................................................................................................. +...........................................................^.^...^.^...^.^...^...^........................................................... +............................................................................................................................................. +..........................................................^.^...^...^...^.^...^.^.^.......................................................... +............................................................................................................................................. +.........................................................^.^.^.^.^.^.....^.^.^...^.^......................................................... +............................................................................................................................................. +........................................................^.^...^...^.^...^.^.^.^...^.^........................................................ +............................................................................................................................................. +.......................................................^.^.^...^.^...^.^...^.^.^.....^....................................................... +............................................................................................................................................. +......................................................^.^...^...^.^.^.^.^.^...^.^.^...^...................................................... +............................................................................................................................................. +.....................................................^.^.^.^.^.^...^.^.^...^.........^.^..................................................... +............................................................................................................................................. +....................................................^...^...^.....^.....^.^.^.^.....^.^.^.................................................... +............................................................................................................................................. +...................................................^...^.^.^.......^...^.....^.^.^...^.^.^................................................... +............................................................................................................................................. +..................................................^.....^.^.^.^.^.^.^.^.^...^...^.^.^.^...^.................................................. +............................................................................................................................................. +.................................................^.^.^...^.^.^.....^.^.^.^.....^...^.^.^.^.^................................................. +............................................................................................................................................. +................................................^.^.....^.^...^.^.^...^.....^.^.^.^.^.^...^.^................................................ +............................................................................................................................................. +...............................................^.^.^.^.^.^.^...^.^...^.^...^.^...^.^.^.^.^.^.^............................................... +............................................................................................................................................. +..............................................^.^.^.^.^.^...^...^...^...^.^.....^.^.^.^.^...^.^.............................................. +............................................................................................................................................. +.............................................^...^.^...^.^.^.......^.^...^.^.^.^.^.^...^.^.....^............................................. +............................................................................................................................................. +............................................^...^.^...^.^.^.....^.....^.^.^.^.^.....^.^.....^...^............................................ +............................................................................................................................................. +...........................................^.^.^.^.^.^.^.^.^.....^.^.^.^.^...^...^.^.^...^.....^.^........................................... +............................................................................................................................................. +..........................................^.^...^.^.^.^.^.^.^...^...^.^.^...^.^.^.^.^.^...^...^.^.^.......................................... +............................................................................................................................................. +.........................................^.^...^...^.......^.^.^.^.^.....^.^.^...^.^.^.^.^.^...^.^.^......................................... +............................................................................................................................................. +........................................^.....^.^.....^.^...^.^...^.^.^.^...........^...^.^...^...^.^........................................ +............................................................................................................................................. +.......................................^.^.^...^.^.^.^.^.^...^.^...^.^.........^.^.^.^.^.^.^.....^.^.^....................................... +............................................................................................................................................. +......................................^.....^.^...........^.^.^.^.......^...^.^.^...^.......^.......^.^...................................... +............................................................................................................................................. +.....................................^.^.^.....^.^.^.^.^.....^...^.^.^.^.^...^.^...^.^...^...^...^...^.^..................................... +............................................................................................................................................. +....................................^.^.....^...^.^...^.^.....^.^.^.^.^...^.^...^.^...^.^.^.^...^...^...^.................................... +............................................................................................................................................. +...................................^...^.^.^.^...^.^...^...^.......^.^.^.^.....^.^.^...^.^...^.^...^.^...^................................... +............................................................................................................................................. +..................................^...^.......^.^.^.^.^.......^.^.^.............^...^.....^...^.^...^.^.^.^.................................. +............................................................................................................................................. +.................................^.^.^.^.......^.....^.^.^...^.....^.....^.^.^.^...^.^...^.^.^...^.......^.^................................. +............................................................................................................................................. +................................^...^.^.^...^.......^...^.^...^...^.^.^.^.^.^.^.....^.^...^.^...^.^...^.^...^................................ +............................................................................................................................................. +...............................^...^.....^.^.^...^...........^.^...^.........^.^.^.^.^...^.^.^.^.^...^.^.^.^.^............................... +............................................................................................................................................. +..............................^.^...^.^.......^.....^.^.^.^...^.^.^...^.^...^.^.^...^.^.^.....^...^.^.^...^...^.............................. +............................................................................................................................................. +.............................^.^.^...^.^.^...^.^.^.^.^.^.....^...^.^.^...^.....^.^.^.^.^...^...^.^.^.^.^.^.....^............................. +............................................................................................................................................. +............................^.^.^...^.^.^...^.^.....^.^...^.^.^.^...^...^...^.^.^.^.^.^...^.......^.^.^.^.^.^.^.^............................ +............................................................................................................................................. +...........................^.^.^.^.^...^...^.^.^.^...^.^.........^.^.^...^.....^.^.^.^...^.^...^.^.....^...^.^.^.^........................... +............................................................................................................................................. +..........................^...^...^.^.^.^.^.^.^.^.^.^.^...^...^...^.^.^.^.^...^.......^.^...^.^.^.^.^.....^.^...^.^.......................... +............................................................................................................................................. +.........................^.^...^.^.^.^.^.^...^...^...^.....^...^.^.^.^...^.....^.^...^.^...^...^...^.^.^.^.^...^...^......................... +............................................................................................................................................. +........................^.^...^...^.^...^.^.^.^.^...^.......^...^.^.....^.^.^.....^...^.^.^.^.^.^.^...^.^...^...^.^.^........................ +............................................................................................................................................. +.......................^.^.^.^.^.^.^...^.......^...^.^.^.^.^.^...^.^.^...........^.^.^.^...^.^.....^.^.^.^...^.^.^...^....................... +............................................................................................................................................. +......................^.^.....^.^...^.^.....^.^.^...^.^.^.^.^.^...^.^.....^.....^...^.^.^.^.^.^.......^.^.^.^...^.^.^.^...................... +............................................................................................................................................. +.....................^.^.^...^.^.^.....^.^.^.^...^...^.^.^.^.^.^.^.^.^.^.^...^.^.........^.^.^.^.^.^.^...^.....^...^...^..................... +............................................................................................................................................. +....................^.......^...^.^.^.^.............^.^.^.^.^...^.^.^.^.^.^.^.^.^.^...^.^.^.^.^.......^...^.^.^.^.^.^.^.^.................... +............................................................................................................................................. +...................^.^.^.^.^.............^.^.^.^.^.^.^.^...^.^.^.^...^.^.^.........^.^...^...^.^.^...^.^.^.^...^.^.^...^.^................... +............................................................................................................................................. +..................^...^.^.^...^.^.^...^.^.^.....^.^.^.^.^.^.^.^...^...........^.^.^...^.....^...^.^.^.......^.^.....^.^.^.^.................. +............................................................................................................................................. +.................^...^.^...^.....^.^.^...^.^.^.^...^.^.^...^...^.^.^.^.^.^.^.....^.^.^.....^...^...^.^.^...^.^...^.^...^...^................. +............................................................................................................................................. +................^.^.^.^.^.^.^.^...^.......^.^.^.....^.^.^...^.....^.^...^.^.^.......^.^.^.^...^.....^.^...^.^.^.^.......^...^................ +............................................................................................................................................. +...............^.^.^.^...^...^.^.^.....^.^.^.^...^.^.^.^.^.^...^.^.^.^...^.^...^.^.^.......^.^.^.^...^.^.^.^.^.^...^.^.^...^.^............... +............................................................................................................................................. +..............^.^...^...^...^...^.^.^.^.^.......^.^.^.^.^...^.....^.^.^.^.......^.^.^.^.^.^.^.^.^...^...^.^.^.^.^.^...^.^...^.^.............. +............................................................................................................................................. +.............^.^...^.^.^...^...^.......^.....^.^...^.......^.^.^.^...^.^.^.^...^.^.^.......^.^.......^.^...^.^.^.^.^.^.^.^.^.^.^............. +............................................................................................................................................. +............^.^...^.^.....^.^.^...^.^...^.^.^.......^.^.^.^.^.^.....^...^.....^.^.^...^.^...^...^.^.^.^.......^.......^.^.^.^.^.^............ +............................................................................................................................................. +...........^.......^...^...^.....^.^...^.^...^...........^.^.^.^...^.......^...^.^.^.....^.^.....^.....^.^...^.^.^.^.^.^.^.....^.^........... +............................................................................................................................................. +..........^.....^.^.....^.^.^.^.^...^.^...^.^.^.^.^.^.^.^...^.^...^...^.^.^.^.^...^.^.....^.^...^...^...^.....^.^.^.^.^.^.^.^.^.^.^.......... +............................................................................................................................................. +.........^.^.^.^.^...^.^...^.^.^...^.^.^...^.^.^.^.^.^.^.^...^.^.^.^.^...^.^.^...^.^...^.^.^.^.^...^...^.^.^.^.....^...^.....^.^.^.^......... +............................................................................................................................................. +........^.^.^...^.^.^.^.^.^.^.^.^.^.....^.....^.^.^.^.^.^...^.^.^.^.^.^.^.^.^.^.....^.^.....^.^.....^.....^...^...^.....^...^.......^........ +............................................................................................................................................. +.......^.^.^.^.^.^.....^.^.^.^.^.^.^...^.^...^.....^.^...^.^.^.^.^...^...^.^.^.^.^.^.....^.^...^.....^.^.^.^.^.^.^.^.^...^.^.^...^...^....... +............................................................................................................................................. +......^.^...^.^...^.^.^.^...^...^...^.^...^.......^.^...^.^.^.....^.^.^.^.^.^...^.^...^...^.^...^.^.^.^.^.^.^.^.......^.^.^...^...^...^...... +............................................................................................................................................. +.....^.^.^.^.^.^.^.....^.....^.^...^...^.^.^...^...^.^...^.^.^.^...^.^.^.^.^.^.^.....^.^.^...^.^.^.^.......^...^.^.......^.^.^.........^..... +............................................................................................................................................. +....^...^.^.^.^...^.....^...^...^.^.^.^.^.^.^.......^.^.^.^.^.^...^.^.....^.^...^.^.......^.^...^...^.^.^.^...^.^.^.^.......^.^.^.^...^.^.... +............................................................................................................................................. +...^.^...^...^.^.^...^.^.^.^.^.^.^.^.^.^.^.^.^.....^.^.^.^.^.^...^...^.^...^.....^.^.....^.^.^...^.^.^.^.^...........^...^...^.^.^.....^.^... +............................................................................................................................................. +..^...........^.^.^.^.^.^.....^...^.^.^.^.^...^.^...^.^.^.^.^.^...^.^...^.^.^...^...^...^.^.^.^.^.^.^...^.^.....^.^.^.^.^.^.^.^.^.^.^.^.^.^.. +............................................................................................................................................. +.^...^...^.^.........^...^.^.^.....^...^...^.^.^.^.^...^.^.^.^.^...^.........^.^...^.^.^...^.^.^.^.^...^.^.^.^.^.^.^.....^.....^.....^.^.^.^. +............................................................................................................................................. diff --git a/2025/7/input_example.txt b/2025/7/input_example.txt new file mode 100644 index 0000000..57a2466 --- /dev/null +++ b/2025/7/input_example.txt @@ -0,0 +1,16 @@ +.......S....... +............... +.......^....... +............... +......^.^...... +............... +.....^.^.^..... +............... +....^.^...^.... +............... +...^.^...^.^... +............... +..^...^.....^.. +............... +.^.^.^.^.^...^. +...............