Skip to content

Instantly share code, notes, and snippets.

@Ranudar
Ranudar / solution_day_6.py
Created December 7, 2024 13:02
aoc2024day6.py
with open(r'..\puzzle_inputs\day_6') as f:
data = f.read()
grid_list = [[position for position in element] for element in data.split("\n")]
grid = {(x, y): grid_list[y][x] for y in range(len(grid_list)) for x in range(len(grid_list[0]))}
GRID_WIDTH, GRID_HEIGHT = (len(grid_list[0]), len(grid_list))
# directions
@Ranudar
Ranudar / aoc2024day5.py
Last active December 5, 2024 21:45
My solution for day 5 of the 2024 Advent of Code. I couldn't wrap my head around how to order the instructions correctly in part 2, so I thought "why not simply let Python sort it out for me ;)".
from collections import defaultdict
with open(r'day_5') as f:
data = f.read()
first_part, second_part = data.split("\n\n")
first_part = [element.split("|") for element in first_part.split("\n")]
first_part = [[int(element) for element in rule] for rule in first_part]
@Ranudar
Ranudar / queens.py
Created February 8, 2024 22:26
My solution to the 10 queens riddle, posed by Rodrigo from Mathspp
from collections import namedtuple
from copy import deepcopy
MIN_ROW, MAX_ROW = 0, 9
MIN_COLUMN, MAX_COLUMN = 0, 9
total_successful_combinations = 0
total_failed_combinations = 0
Field = namedtuple('Field', 'row, column')
from random import choice, shuffle
class Monty_Hall:
"""This represents the initial puzzle setup with three doors."""
def __init__(self):
self.doors_to_chose_from = ["goat_1", "goat_2", "car"]
shuffle(self.doors_to_chose_from)
def __call__(self, change=True):