Skip to content

Instantly share code, notes, and snippets.

View object's full-sized avatar

Vagif Abilov object

View GitHub Profile
@object
object / AdventOfCode2024.Day14.py
Last active December 14, 2024 14:22
Advent of Code 2024, day 14
import re
with open("./data/input14.txt") as inputFile:
input = inputFile.read().splitlines()
init = []
for line in input:
m = re.findall(r'p=(-?\d+),(-?\d+) v=(-?\d+),(-?\d+)', line)
p = (int(m[0][0]), int(m[0][1]))
@object
object / AdventOfCode2024.Day13.py
Created December 13, 2024 07:11
Advent of Code 2024, day 13
from itertools import groupby
import re
with open("./data/input13.txt") as inputFile:
input = inputFile.read().splitlines()
groups = [list(sub) for is_empty, sub in groupby(input, key = lambda x: x == '') if not is_empty]
machines = []
for group in groups:
@object
object / AdventOfCode2024.Day11.py
Last active December 11, 2024 11:07
Advent of Code 2024, day 11
import sys
from itertools import combinations
sys.setrecursionlimit(10**6)
with open("./data/input11.txt") as inputFile:
input = inputFile.read()
stones = []
for num in input.split(' '):
@object
object / AdventOfCode2024.Day10.py
Last active December 10, 2024 08:23
Advent of Code 2024, day 10
import sys
from itertools import combinations
sys.setrecursionlimit(10**6)
with open("./data/input10.txt") as inputFile:
input = inputFile.read().splitlines()
trailheads = []
grid = []
@object
object / AdventOfCode2024.Day09.py
Created December 9, 2024 08:36
Advent of Code 2024, day 09
with open("./data/input09.txt") as inputFile:
input = inputFile.read()
fs = []
total_free_blocks = 0
i = 0
while i < len(input):
file_id = i // 2
file_size = int(input[i])
free_blocks = 0 if i == len(input)-1 else int(input[i+1])
@object
object / AdventOfCode2024.Day08.py
Created December 8, 2024 08:36
Advent of Code 2024, day 08
import sys
from itertools import combinations
sys.setrecursionlimit(10**6)
with open("./data/input08.txt") as inputFile:
input = inputFile.read().splitlines()
antennas = {}
for r in range(len(input)):
@object
object / AdventOfCode2024.Day07.py
Created December 7, 2024 06:02
Advent of Code 2024, day 07
import sys
sys.setrecursionlimit(10**6)
with open("./data/input07.txt") as inputFile:
input = inputFile.read().splitlines()
equations = []
for line in input:
tokens = line.split(': ')
@object
object / AdventOfCode2024.Day05.py
Created December 5, 2024 05:52
Advent of Code 2024, day 05
with open("./data/input05.txt") as inputFile:
input = inputFile.read().splitlines()
orders = set()
updates = []
for line in input:
if '|' in line:
pages = line.split('|')
orders.add((int(pages[0]), int(pages[1])))
@object
object / AdventOfCode2024.Day04.py
Created December 4, 2024 07:36
Advent of Code 2024, day 04
import re
with open("./data/input04.txt") as inputFile:
input = inputFile.read().splitlines()
upper_bound = len(input)-1
def rev(ar): return ar[::-1]
# Part 1
@object
object / AdventOfCode2024.Day03.py
Last active December 3, 2024 07:01
Advent of Code 2024, day 03
import re
with open("./data/input03.txt") as inputFile:
input = inputFile.read()
def evaluate(expr):
m = re.findall(r'\d{1,3}', expr)
return int(m[0]) * int(m[1])
# Part 1