Created
December 9, 2025 21:01
-
-
Save DarthJahus/ff3bf69d1bd9e6cd209a8e3c890cf2dc to your computer and use it in GitHub Desktop.
Advent of Code - Year 2025 - Day 7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://adventofcode.com/2025/day/7 | |
| # Jahus | |
| def split_it(input): | |
| _source = (None, None) | |
| _split_count = 0 | |
| _result = input.copy() | |
| for l in range(len(_result)): | |
| _new_line = [c for c in _result[l]] | |
| for p in range(len(_result[l])): | |
| if _result[l][p] == "S": | |
| _source = (l, p) | |
| _new_line[p] = 'S' | |
| elif _result[l][p] == "." and _result[l-1][p] in ['|', 'S']: | |
| _new_line[p] = '|' | |
| elif _result[l][p] == "^" and _result[l-1][p] in ['|', 'S']: | |
| _new_line[p] = "^" | |
| try: | |
| _new_line[p-1] = "|" | |
| except IndexError: | |
| pass # out of bounds | |
| try: | |
| _new_line[p+1] = "|" | |
| except IndexError: | |
| pass # out of bounds | |
| _split_count += 1 | |
| else: | |
| pass | |
| try: | |
| _result[l] = ''.join(_new_line) | |
| except IndexError: | |
| pass # out of range | |
| return _result, _split_count, _source | |
| def check_result(correct, user): | |
| try: | |
| for l in range(len(correct)): | |
| for c in range(len(correct[l])): | |
| if correct[l][c].strip().lower() != user[l][c].strip().lower(): | |
| print(l, c) | |
| raise | |
| except: | |
| return False | |
| return True | |
| if __name__ == "__main__": | |
| _in = [ | |
| ".......S.......", | |
| "...............", | |
| ".......^.......", | |
| "...............", | |
| "......^.^......", | |
| "...............", | |
| ".....^.^.^.....", | |
| "...............", | |
| "....^.^...^....", | |
| "...............", | |
| "...^.^...^.^...", | |
| "...............", | |
| "..^...^.....^..", | |
| "...............", | |
| ".^.^.^.^.^...^.", | |
| "..............." | |
| ] | |
| _correct_result = [ | |
| ".......S.......", | |
| ".......|.......", | |
| "......|^|......", | |
| "......|.|......", | |
| ".....|^|^|.....", | |
| ".....|.|.|.....", | |
| "....|^|^|^|....", | |
| "....|.|.|.|....", | |
| "...|^|^|||^|...", | |
| "...|.|.|||.|...", | |
| "..|^|^|||^|^|..", | |
| "..|.|.|||.|.|..", | |
| ".|^|||^||.||^|.", | |
| ".|.|||.||.||.|.", | |
| "|^|^|^|^|^|||^|", | |
| "|.|.|.|.|.|||.|" | |
| ] | |
| _user_result = split_it(_in) | |
| print(f"Source detected at ({_user_result[2][0]}, {_user_result[2][1]}).\nResult:\n{'\n'.join(_user_result[0])}\n\nSplit count: {_user_result[1]}") | |
| print('\nCorrect !' if check_result(_correct_result, _user_result[0]) else 'Faux !') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment