Dataset Viewer
Auto-converted to Parquet Duplicate
year
stringdate
2024-01-01 00:00:00
2024-01-01 00:00:00
day
stringclasses
25 values
part
stringclasses
2 values
question
stringclasses
50 values
answer
stringclasses
49 values
solution
stringlengths
143
12.8k
language
stringclasses
3 values
2024
2
1
--- Day 2: Red-Nosed Reports --- Fortunately, the first location The Historians want to search isn't a long walk from the Chief Historian's office. While the Red-Nosed Reindeer nuclear fusion/fission plant appears to contain no sign of the Chief Historian, the engineers there run up to you as soon as they see you. Ap...
341
def parseInput(): input = [] with open('input.txt', 'r') as file: tmp = file.read().splitlines() tmp2 = [i.split(' ') for i in tmp] for item in tmp2: input.append([int(i) for i in item]) return input if __name__ == "__main__": input = parseInput() ...
python
2024
2
1
--- Day 2: Red-Nosed Reports --- Fortunately, the first location The Historians want to search isn't a long walk from the Chief Historian's office. While the Red-Nosed Reindeer nuclear fusion/fission plant appears to contain no sign of the Chief Historian, the engineers there run up to you as soon as they see you. Ap...
341
import sys input_path = sys.argv[1] if len(sys.argv) > 1 else "input.txt" def solve(input): with open(input) as f: lines = f.read().splitlines() L = [list(map(int, line.split(" "))) for line in lines] # L = [[int(l) for l in line.split(" ")] for line in lines] counter = 0 for l in L: ...
python
2024
2
1
--- Day 2: Red-Nosed Reports --- Fortunately, the first location The Historians want to search isn't a long walk from the Chief Historian's office. While the Red-Nosed Reindeer nuclear fusion/fission plant appears to contain no sign of the Chief Historian, the engineers there run up to you as soon as they see you. Ap...
341
l = [list(map(int,x.split())) for x in open("i.txt")] print(sum(any(all(d<b-a<u for a,b in zip(s,s[1:])) for d,u in[(0,4),(-4,0)])for s in l))
python
2024
2
1
--- Day 2: Red-Nosed Reports --- Fortunately, the first location The Historians want to search isn't a long walk from the Chief Historian's office. While the Red-Nosed Reindeer nuclear fusion/fission plant appears to contain no sign of the Chief Historian, the engineers there run up to you as soon as they see you. Ap...
341
import sys input_path = sys.argv[1] if len(sys.argv) > 1 else "input.txt" def solve(input): with open(input) as f: lines = f.read().splitlines() L = [list(map(int, line.split(" "))) for line in lines] counter = 0 for l in L: inc_dec = l == sorted(l) or l == sorted(l, reverse=True) ...
python
2024
2
1
--- Day 2: Red-Nosed Reports --- Fortunately, the first location The Historians want to search isn't a long walk from the Chief Historian's office. While the Red-Nosed Reindeer nuclear fusion/fission plant appears to contain no sign of the Chief Historian, the engineers there run up to you as soon as they see you. Ap...
341
with open('input.txt', 'r') as file: lines = file.readlines() sum = 0 for line in lines: A = [int(x) for x in line.split()] ascending = False valid = True if A[0] < A[1]: ascending = True for i in range(len(A) - 1): if ascending: ...
python
2024
2
2
--- Day 2: Red-Nosed Reports --- Fortunately, the first location The Historians want to search isn't a long walk from the Chief Historian's office. While the Red-Nosed Reindeer nuclear fusion/fission plant appears to contain no sign of the Chief Historian, the engineers there run up to you as soon as they see you. Ap...
404
def is_safe(levels: list[int]) -> bool: # Calculate the difference between each report differences = [first - second for first, second in zip(levels, levels[1:])] max_difference = 3 return (all(0 < difference <= max_difference for difference in differences) or all(-max_difference <= differe...
python
2024
2
2
--- Day 2: Red-Nosed Reports --- Fortunately, the first location The Historians want to search isn't a long walk from the Chief Historian's office. While the Red-Nosed Reindeer nuclear fusion/fission plant appears to contain no sign of the Chief Historian, the engineers there run up to you as soon as they see you. Ap...
404
def if_asc(x): result = all(y < z for y,z in zip(x, x[1:])) return result def if_dsc(x): result = all (y > z for y,z in zip(x, x[1:])) return result def if_asc_morethan3(x): result = all(y > z - 4 for y,z in zip(x,x[1:])) return result def if_dsc_morethan3(x): result = all(y < z + 4 for y...
python
2024
2
2
--- Day 2: Red-Nosed Reports --- Fortunately, the first location The Historians want to search isn't a long walk from the Chief Historian's office. While the Red-Nosed Reindeer nuclear fusion/fission plant appears to contain no sign of the Chief Historian, the engineers there run up to you as soon as they see you. Ap...
404
import sys import logging # logging.basicConfig(,level=sys.argv[2]) input_path = sys.argv[1] if len(sys.argv) > 1 else "input.txt" def is_ok(lst): inc_dec = lst == sorted(lst) or lst == sorted(lst, reverse=True) size_ok = True for i in range(len(lst) - 1): if not 0 < abs(lst[i] - lst[i + 1]) <= ...
python
2024
2
2
--- Day 2: Red-Nosed Reports --- Fortunately, the first location The Historians want to search isn't a long walk from the Chief Historian's office. While the Red-Nosed Reindeer nuclear fusion/fission plant appears to contain no sign of the Chief Historian, the engineers there run up to you as soon as they see you. Ap...
404
count = 0 def safe(levels): # Check if the sequence is either all increasing or all decreasing if all(levels[i] < levels[i + 1] for i in range(len(levels) - 1)): # Increasing diffs = [levels[i + 1] - levels[i] for i in range(len(levels) - 1)] elif all(levels[i] > levels[i + 1] for i in range(len(l...
python
2024
2
2
--- Day 2: Red-Nosed Reports --- Fortunately, the first location The Historians want to search isn't a long walk from the Chief Historian's office. While the Red-Nosed Reindeer nuclear fusion/fission plant appears to contain no sign of the Chief Historian, the engineers there run up to you as soon as they see you. Ap...
404
def check_sequence(numbers): nums = [int(x) for x in numbers.split()] # First check if sequence is valid as is if is_valid_sequence(nums): return True # Try removing one number at a time for i in range(len(nums)): test_nums = nums[:i] + nums[i+1:] if is_valid_se...
python
2024
1
1
--- Day 1: Historian Hysteria --- The Chief Historian is always present for the big Christmas sleigh launch, but nobody has seen him in months! Last anyone heard, he was visiting locations that are historically significant to the North Pole; a group of Senior Historians has asked you to accompany them as they check th...
2378066
def parseInput(): left = [] right = [] with open('input.txt', 'r') as file: input = file.read().splitlines() for line in input: split = line.split(" ") left.append(int(split[0])) right.append(int(split[1])) return left, right def sort(arr: list): ...
python
2024
1
1
--- Day 1: Historian Hysteria --- The Chief Historian is always present for the big Christmas sleigh launch, but nobody has seen him in months! Last anyone heard, he was visiting locations that are historically significant to the North Pole; a group of Senior Historians has asked you to accompany them as they check th...
2378066
def find_min_diff(a, b): sorted_a = sorted(a) sorted_b = sorted(b) d = 0 for i in range(len(sorted_a)): d += abs(sorted_a[i] - sorted_b[i]) return d def read_input_file(file_name): a = [] b = [] with open(file_name, "r") as file: for line in file: values = l...
python
2024
1
1
--- Day 1: Historian Hysteria --- The Chief Historian is always present for the big Christmas sleigh launch, but nobody has seen him in months! Last anyone heard, he was visiting locations that are historically significant to the North Pole; a group of Senior Historians has asked you to accompany them as they check th...
2378066
input = open("day_01\input.txt", "r") distance = 0 left_list = [] right_list = [] for line in input: values = [x for x in line.strip().split()] left_list += [int(values[0])] right_list += [int(values[1])] left_list.sort() right_list.sort() for i in range(len(left_list)): distance += abs(left_lis...
python
2024
1
1
--- Day 1: Historian Hysteria --- The Chief Historian is always present for the big Christmas sleigh launch, but nobody has seen him in months! Last anyone heard, he was visiting locations that are historically significant to the North Pole; a group of Senior Historians has asked you to accompany them as they check th...
2378066
def read_input(file_path: str) -> list[tuple[int, int]]: """ Reads a file and returns its contents as a list of tuples of integers. Args: file_path (str): The path to the input file. Returns: list of tuple of int: A list where each element is a tuple of integers representing a...
python
2024
1
1
--- Day 1: Historian Hysteria --- The Chief Historian is always present for the big Christmas sleigh launch, but nobody has seen him in months! Last anyone heard, he was visiting locations that are historically significant to the North Pole; a group of Senior Historians has asked you to accompany them as they check th...
2378066
with open("AdventOfCode D-1 input.txt", "r") as file: content = file.read() lines = content.splitlines() liste_1 = [] liste_2 = [] for i in range(len(lines)): mots = lines[i].split() liste_1.append(int(mots[0])) liste_2.append(int(mots[1])) liste_paires = [] index = 0 while liste_1 != []: list...
python
2024
1
2
--- Day 1: Historian Hysteria --- The Chief Historian is always present for the big Christmas sleigh launch, but nobody has seen him in months! Last anyone heard, he was visiting locations that are historically significant to the North Pole; a group of Senior Historians has asked you to accompany them as they check th...
18934359
def calculate_similarity_score(left, right): score = 0 for left_element in left: score += left_element * num_times_in_list(left_element, right) return score def num_times_in_list(number, right_list): num_times = 0 for element in right_list: if number == element: num_time...
python
2024
1
2
--- Day 1: Historian Hysteria --- The Chief Historian is always present for the big Christmas sleigh launch, but nobody has seen him in months! Last anyone heard, he was visiting locations that are historically significant to the North Pole; a group of Senior Historians has asked you to accompany them as they check th...
18934359
leftNums, rightNums = [], [] with open('input.txt') as input: while line := input.readline().strip(): left, right = line.split() leftNums.append(int(left.strip())) rightNums.append(int(right.strip())) total = 0 for i in range(len(leftNums)): total += leftNums[i] * rightNums.count(leftN...
python
2024
1
2
--- Day 1: Historian Hysteria --- The Chief Historian is always present for the big Christmas sleigh launch, but nobody has seen him in months! Last anyone heard, he was visiting locations that are historically significant to the North Pole; a group of Senior Historians has asked you to accompany them as they check th...
18934359
import re import heapq from collections import Counter f = open('day1.txt', 'r') list1 = [] list2 = [] for line in f: splitLine = re.split(r"\s+", line.strip()) list1.append(int(splitLine[0])) list2.append(int(splitLine[1])) list2Count = Counter(list2) similarityScore = 0 for num in list1: if num in...
python
2024
1
2
--- Day 1: Historian Hysteria --- The Chief Historian is always present for the big Christmas sleigh launch, but nobody has seen him in months! Last anyone heard, he was visiting locations that are historically significant to the North Pole; a group of Senior Historians has asked you to accompany them as they check th...
18934359
from collections import defaultdict with open("day_01.in") as fin: data = fin.read() ans = 0 a = [] b = [] for line in data.strip().split("\n"): nums = [int(i) for i in line.split(" ")] a.append(nums[0]) b.append(nums[1]) counts = defaultdict(int) for x in b: counts[x] += 1 for x in a: an...
python
2024
1
2
--- Day 1: Historian Hysteria --- The Chief Historian is always present for the big Christmas sleigh launch, but nobody has seen him in months! Last anyone heard, he was visiting locations that are historically significant to the North Pole; a group of Senior Historians has asked you to accompany them as they check th...
18934359
input = open("Day 1\input.txt", "r") list1 = [] list2 = [] for line in input: nums = line.split(" ") list1.append(int(nums[0])) list2.append(int(nums[-1])) list1.sort() list2.sort() total = 0 for i in range(len(list1)): num1 = list1[i] simscore = 0 for j in range(len(list2)): num2 = list...
python
2024
3
1
--- Day 3: Mull It Over --- "Our computers are having issues, so I have no idea if we have any Chief Historians in stock! You're welcome to check the warehouse, though," says the mildly flustered shopkeeper at the North Pole Toboggan Rental Shop. The Historians head out to take a look. The shopkeeper turns to you. "A...
170807108
import re def runOps(ops: str) -> int: # I am not proud of this ew = ops[4:-1].split(',') return int(ew[0]) * int(ew[1]) def part1(): with open("./input.txt") as f: pattern = re.compile("mul\\(\\d+,\\d+\\)") ops = re.findall(pattern, f.read()) sum: int = 0 for o in ops...
python
2024
3
1
--- Day 3: Mull It Over --- "Our computers are having issues, so I have no idea if we have any Chief Historians in stock! You're welcome to check the warehouse, though," says the mildly flustered shopkeeper at the North Pole Toboggan Rental Shop. The Historians head out to take a look. The shopkeeper turns to you. "A...
170807108
#!/usr/bin/python3 import re with open("input.txt") as file: instructions_cor = file.read() instructions = re.findall(r"mul\(([0-9]+,[0-9]+)\)", instructions_cor) mul_inp = [instruction.split(",") for instruction in instructions] mul_results = [int(instruction[0]) * int(instruction[1]) for instruction in mul_i...
python
2024
3
1
--- Day 3: Mull It Over --- "Our computers are having issues, so I have no idea if we have any Chief Historians in stock! You're welcome to check the warehouse, though," says the mildly flustered shopkeeper at the North Pole Toboggan Rental Shop. The Historians head out to take a look. The shopkeeper turns to you. "A...
170807108
import re def read_input_file(file_name): a = [] with open(file_name, "r") as file: for line in file: values = line.strip().split() a.append(values) return a def main(): max = 0 text = read_input_file('input.txt') pattern = r"mul\((\d+),(\d+)\)" for line in...
python
2024
3
1
--- Day 3: Mull It Over --- "Our computers are having issues, so I have no idea if we have any Chief Historians in stock! You're welcome to check the warehouse, though," says the mildly flustered shopkeeper at the North Pole Toboggan Rental Shop. The Historians head out to take a look. The shopkeeper turns to you. "A...
170807108
import re with open('input.txt', 'r') as file: input = file.read() pattern = r"mul\(\d{1,3},\d{1,3}\)" matches = re.findall(pattern, input) sum = 0 for match in matches: sum += eval(match.replace("mul(", "").replace(")", "").replace(",", "*")) print(sum)
python
2024
3
1
--- Day 3: Mull It Over --- "Our computers are having issues, so I have no idea if we have any Chief Historians in stock! You're welcome to check the warehouse, though," says the mildly flustered shopkeeper at the North Pole Toboggan Rental Shop. The Historians head out to take a look. The shopkeeper turns to you. "A...
170807108
import re import sys input_path = sys.argv[1] if len(sys.argv) > 1 else "input.txt" with open(input_path) as f: text = f.read() pattern = r"mul\(\d+,\d+\)" matches = re.findall(pattern, text) p2 = r"\d+" # print(matches) result = 0 for match in matches: nums = re.findall(p2, match) result += int(nums[0])...
python
2024
3
2
--- Day 3: Mull It Over --- "Our computers are having issues, so I have no idea if we have any Chief Historians in stock! You're welcome to check the warehouse, though," says the mildly flustered shopkeeper at the North Pole Toboggan Rental Shop. The Historians head out to take a look. The shopkeeper turns to you. "A...
74838033
import re with open("day3.txt", "r") as f: data = f.read().splitlines() pattern = r"mul\((\d+),(\d+)\)|do\(\)|don't\(\)" sum = 0 current = 1 for row in data: match = re.finditer( pattern, row, ) for mul in match: command = mul.group(0) if command == "do()": ...
python
2024
3
2
--- Day 3: Mull It Over --- "Our computers are having issues, so I have no idea if we have any Chief Historians in stock! You're welcome to check the warehouse, though," says the mildly flustered shopkeeper at the North Pole Toboggan Rental Shop. The Historians head out to take a look. The shopkeeper turns to you. "A...
74838033
from re import findall with open("input.txt") as input_file: input_text = input_file.read() total = 0 do = True for res in findall(r"mul\((\d+),(\d+)\)|(don't\(\))|(do\(\))", input_text): if do and res[0]: total += int(res[0]) * int(res[1]) elif do and res[2]: do = False elif (not do) a...
python
2024
3
2
--- Day 3: Mull It Over --- "Our computers are having issues, so I have no idea if we have any Chief Historians in stock! You're welcome to check the warehouse, though," says the mildly flustered shopkeeper at the North Pole Toboggan Rental Shop. The Historians head out to take a look. The shopkeeper turns to you. "A...
74838033
import re def sumInstructions(instructions): return sum([int(x) * int(y) for x, y in instructions]) def getTuples(instructions): return re.findall(r'mul\(([0-9]{1,3}),([0-9]{1,3})\)', instructions) def main(): total = 0 with open('input.txt') as input: line = input.read() split = re.s...
python
2024
3
2
--- Day 3: Mull It Over --- "Our computers are having issues, so I have no idea if we have any Chief Historians in stock! You're welcome to check the warehouse, though," says the mildly flustered shopkeeper at the North Pole Toboggan Rental Shop. The Historians head out to take a look. The shopkeeper turns to you. "A...
74838033
import re from functools import reduce pattern = r'mul\(\d{1,3},\d{1,3}\)|do\(\)|don\'t\(\)' num_pattern = r'\d{1,3}' with open('input.txt', 'r') as f: data = f.read() print(data) matches = re.findall(pattern, data) res = 0 doCompute = True for match in matches: print(match) if...
python
2024
3
2
--- Day 3: Mull It Over --- "Our computers are having issues, so I have no idea if we have any Chief Historians in stock! You're welcome to check the warehouse, though," says the mildly flustered shopkeeper at the North Pole Toboggan Rental Shop. The Historians head out to take a look. The shopkeeper turns to you. "A...
74838033
import re with open('input.txt', 'r') as file: input = file.read() do_pattern = r"do\(\)" dont_pattern = r"don't\(\)" do_matches = re.finditer(do_pattern, input) dont_matches = re.finditer(dont_pattern, input) do_indexes = [x.start() for x in do_matches] dont_indexes = [x.start() for x i...
python
2024
4
1
--- Day 4: Ceres Search --- "Looks like the Chief's not here. Next!" One of The Historians pulls out a device and pushes the only button on it. After a brief flash, you recognize the interior of the Ceres monitoring station! As the search for the Chief continues, a small Elf who lives on the station tugs on your shir...
2434
DIRECTIONS = [ (1, 0), (0, 1), (-1, 0), (0, -1), (1, 1), (-1, -1), (-1, 1), (1, -1), ] def count_xmas(x, y): count = 0 for dx, dy in DIRECTIONS: if all( 0 <= x + i * dx < width and 0 <= y + i * dy < height and words[x + i * dx][y + i *...
python
2024
4
1
--- Day 4: Ceres Search --- "Looks like the Chief's not here. Next!" One of The Historians pulls out a device and pushes the only button on it. After a brief flash, you recognize the interior of the Ceres monitoring station! As the search for the Chief continues, a small Elf who lives on the station tugs on your shir...
2434
from typing import List import pprint INPUT_FILE: str = "input.txt" def readInput() -> List[List[str]]: with open(INPUT_FILE, 'r') as f: lines = f.readlines() return [list(line.strip()) for line in lines] def search2D(grid, row, col, word): # Directions: right, down, left, up, diagonal down-r...
python
2024
4
1
--- Day 4: Ceres Search --- "Looks like the Chief's not here. Next!" One of The Historians pulls out a device and pushes the only button on it. After a brief flash, you recognize the interior of the Ceres monitoring station! As the search for the Chief continues, a small Elf who lives on the station tugs on your shir...
2434
with open("./day_04.in") as fin: lines = fin.read().strip().split("\n") n = len(lines) m = len(lines[0]) # Generate all directions dd = [] for dx in range(-1, 2): for dy in range(-1, 2): if dx != 0 or dy != 0: dd.append((dx, dy)) # dd = [(-1, -1), (-1, 0), (-1, 1), # (0, -1), ...
python
2024
4
1
--- Day 4: Ceres Search --- "Looks like the Chief's not here. Next!" One of The Historians pulls out a device and pushes the only button on it. After a brief flash, you recognize the interior of the Ceres monitoring station! As the search for the Chief continues, a small Elf who lives on the station tugs on your shir...
2434
import time def solve_part_1(text: str): word = "XMAS" matrix = [ [x for x in line.strip()] for line in text.splitlines() if line.strip() != "" ] rows, cols = len(matrix), len(matrix[0]) word_length = len(word) directions = [ (0, 1), # Right (1, 0), # Down (0...
python
2024
4
1
--- Day 4: Ceres Search --- "Looks like the Chief's not here. Next!" One of The Historians pulls out a device and pushes the only button on it. After a brief flash, you recognize the interior of the Ceres monitoring station! As the search for the Chief continues, a small Elf who lives on the station tugs on your shir...
2434
from re import findall with open("input.txt") as input_file: input_text = input_file.read().splitlines() num_rows = len(input_text) num_cols = len(input_text[0]) total = 0 # Rows for row in input_text: total += len(findall(r"XMAS", row)) total += len(findall(r"XMAS", row[::-1])) # Columns for col_idx in...
python
2024
4
2
--- Day 4: Ceres Search --- "Looks like the Chief's not here. Next!" One of The Historians pulls out a device and pushes the only button on it. After a brief flash, you recognize the interior of the Ceres monitoring station! As the search for the Chief continues, a small Elf who lives on the station tugs on your shir...
1835
FNAME = "data.txt" WORD = "MMASS" def main(): matrix = file_to_matrix(FNAME) print(count_word(matrix, WORD)) def file_to_matrix(fname: str) -> list[list]: out = [] fopen = open(fname, "r") for line in fopen: out.append([c for c in line if c != "\n"]) return out def count_word(matrix:...
python
2024
4
2
--- Day 4: Ceres Search --- "Looks like the Chief's not here. Next!" One of The Historians pulls out a device and pushes the only button on it. After a brief flash, you recognize the interior of the Ceres monitoring station! As the search for the Chief continues, a small Elf who lives on the station tugs on your shir...
1835
template = [ "S..S..S", ".A.A.A.", "..MMM.." "SAMXMAS", "..MMM.." ".A.A.A.", "S..S..S", ] def find_xmas(lines: str) -> int: total = 0 for row in range(len(lines)): for col in range(len(lines[row])): if lines[row][col] == "X": # Horizontal ...
python
2024
4
2
--- Day 4: Ceres Search --- "Looks like the Chief's not here. Next!" One of The Historians pulls out a device and pushes the only button on it. After a brief flash, you recognize the interior of the Ceres monitoring station! As the search for the Chief continues, a small Elf who lives on the station tugs on your shir...
1835
# PROMPT # ----------------------------------------------------------------------------- # As the search for the Chief continues, a small Elf who lives on the # station tugs on your shirt; she'd like to know if you could help her # with her word search (your puzzle input). She only has to find one word: XMAS. # This...
python
2024
4
2
--- Day 4: Ceres Search --- "Looks like the Chief's not here. Next!" One of The Historians pulls out a device and pushes the only button on it. After a brief flash, you recognize the interior of the Ceres monitoring station! As the search for the Chief continues, a small Elf who lives on the station tugs on your shir...
1835
import re def get_grids_3x3(grid, grid_len): subgrids = [] for row_start in range(grid_len - 2): for col_start in range(grid_len - 2): subgrid = [row[col_start:col_start + 3] for row in grid[row_start:row_start + 3]] subgrids.append(subgrid) return subgrids input = [line.s...
python
2024
4
2
--- Day 4: Ceres Search --- "Looks like the Chief's not here. Next!" One of The Historians pulls out a device and pushes the only button on it. After a brief flash, you recognize the interior of the Ceres monitoring station! As the search for the Chief continues, a small Elf who lives on the station tugs on your shir...
1835
cont = [list(i.strip()) for i in open("day4input.txt").readlines()] def get_neighbors(matrix, x, y): rows = len(matrix) cols = len(matrix[0]) neighbors = [] directions = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0,0), (0, 1), (1, -1), (1, 0), (1, 1)] for dx, dy in directions: nx, ny = x ...
python
2024
5
1
--- Day 5: Print Queue --- Satisfied with their search on Ceres, the squadron of scholars suggests subsequently scanning the stationery stacks of sub-basement 17. The North Pole printing department is busier than ever this close to Christmas, and while The Historians continue their search of this historically signifi...
4766
page_pairs = {} page_updates = [] def main(): read_puzzle_input() check_page_updates() def read_puzzle_input(): with open('puzzle-input.txt', 'r') as puzzle_input: for line in puzzle_input: if "|" in line: page_pair = line.strip().split("|") if page_pa...
python
2024
5
1
--- Day 5: Print Queue --- Satisfied with their search on Ceres, the squadron of scholars suggests subsequently scanning the stationery stacks of sub-basement 17. The North Pole printing department is busier than ever this close to Christmas, and while The Historians continue their search of this historically signifi...
4766
#!/usr/bin/python3 input_file = "./sample_input_1.txt" #input_file = "./input_1.txt" # Sample input """ 47|53 97|13 97|61 ... 75,47,61,53,29 97,61,53,29,13 75,29,13 75,97,47,61,53 61,13,29 97,13,75,29,47 """ with open(input_file, "r") as data: lines = data.readlines() rules =[] updates = [] for li...
python
2024
5
1
--- Day 5: Print Queue --- Satisfied with their search on Ceres, the squadron of scholars suggests subsequently scanning the stationery stacks of sub-basement 17. The North Pole printing department is busier than ever this close to Christmas, and while The Historians continue their search of this historically signifi...
4766
with open('input.txt', 'r') as file: rules = [] lists = [] lines = file.readlines() i = 0 #Write the rule list while len(lines[i]) > 1: rules.append(lines[i].strip().split('|')) i += 1 i += 1 #Write the "update" list while i < len(lines): lists.append(lines[...
python
2024
5
1
--- Day 5: Print Queue --- Satisfied with their search on Ceres, the squadron of scholars suggests subsequently scanning the stationery stacks of sub-basement 17. The North Pole printing department is busier than ever this close to Christmas, and while The Historians continue their search of this historically signifi...
4766
# PROMPT # ----------------------------------------------------------------------------- # Safety protocols clearly indicate that new pages for the safety manuals must be # printed in a very specific order. The notation X|Y means that if both page # number X and page number Y are to be produced as part of an update,...
python
2024
5
1
--- Day 5: Print Queue --- Satisfied with their search on Ceres, the squadron of scholars suggests subsequently scanning the stationery stacks of sub-basement 17. The North Pole printing department is busier than ever this close to Christmas, and while The Historians continue their search of this historically signifi...
4766
def checkValid(beforeDict, update): for i in range(len(update)): # for each number num = update[i] for j in range(i + 1, len(update)): # for each number after current number if not num in beforeDict: return False val = update[j] # print(f" -> checking: {be...
python
2024
5
2
--- Day 5: Print Queue --- Satisfied with their search on Ceres, the squadron of scholars suggests subsequently scanning the stationery stacks of sub-basement 17. The North Pole printing department is busier than ever this close to Christmas, and while The Historians continue their search of this historically signifi...
6257
from collections import defaultdict with open("./day_05.in") as fin: raw_rules, updates = fin.read().strip().split("\n\n") rules = [] for line in raw_rules.split("\n"): a, b = line.split("|") rules.append((int(a), int(b))) updates = [list(map(int, line.split(","))) for line in updates.s...
python
End of preview. Expand in Data Studio

Advent of Code ECV Dataset

Many code generation datasets focus on syntax and structure but lack a strong emphasis on contextual understanding, especially from a storytelling perspective.
The Advent of Code ECV (Expanded, Curated, Verified) Dataset addresses this gap by curating and verifying multiple approaches for each challenge from 2024 to provide diverse solutions, comparison of strategies, and better adaptability across different programming paradigms.
In addition to training and evaluation data, each problem includes at least three test cases for validation.

Key Features

Multi-language support: Python, JavaScript & Ruby solutions (more languages will be added in future updates).
Enriched solutions: Each part of every question includes at least 5 different solutions for diversity.
Test cases: Every problem comes with three test cases for validation.

Statistics:

Year Language Day Total
2024 Python 1 to 25 245
2024 Javascript 1 to 25 245
2024 Ruby 1 to 25 245

Data Fields

β€’ Year (String): The year of the Advent of Code challenge.
β€’ Day (String): The specific day of the challenge.
β€’ Part (String): Indicates whether the solution is for Part 1 or Part 2 of the daily challenge.
β€’ Question (String): The full problem statement for the given day and part.
β€’ Answer (String): The correct final output for the problem, as computed from the input.
β€’ Solution (String): A verified code implementation that solves the problem.
β€’ Language (String): The programming language in which the solution is written.

Data Instance Example:

{
    "Year": "2024",
    "Day": "1",
    "Part": "1",
    "Question": "--- Day 1: Historian Hysteria ---

The Chief Historian is always present for the big Christmas sleigh launch, but nobody has seen him in months! Last anyone heard, he was visiting locations that are historically significant to the North Pole; a group of Senior Historians has asked you to accompany them as they check the places they think he was most likely to visit.

As each location is checked, they will mark it on their list with a star. They figure the Chief Historian must be in one of the first fifty places they'll look, so in order to save Christmas, you need to help them get fifty stars on their list before Santa takes off on December 25th.

Collect stars by solving puzzles. Two puzzles will be made available on each day in the Advent calendar; the second puzzle is unlocked when you complete the first. Each puzzle grants one star. Good luck!

You haven't even left yet and the group of Elvish Senior Historians has already hit a problem: their list of locations to check is currently empty. Eventually, someone decides that the best place to check first would be the Chief Historian's office.

Upon pouring into the office, everyone confirms that the Chief Historian is indeed nowhere to be found. Instead, the Elves discover an assortment of notes and lists of historically significant locations! This seems to be the planning the Chief Historian was doing before he left. Perhaps these notes can be used to determine which locations to search?

Throughout the Chief's office, the historically significant locations are listed not by name but by a unique number called the location ID. To make sure they don't miss anything, The Historians split into two groups, each searching the office and trying to create their own complete list of location IDs.

There's just one problem: by holding the two lists up side by side (your puzzle input), it quickly becomes clear that the lists aren't very similar. Maybe you can help The Historians reconcile their lists?

For example:

3   4
4   3
2   5
1   3
3   9
3   3
Maybe the lists are only off by a small amount! To find out, pair up the numbers and measure how far apart they are. Pair up the smallest number in the left list with the smallest number in the right list, then the second-smallest left number with the second-smallest right number, and so on.

Within each pair, figure out how far apart the two numbers are; you'll need to add up all of those distances. For example, if you pair up a 3 from the left list with a 7 from the right list, the distance apart is 4; if you pair up a 9 with a 3, the distance apart is 6.

In the example list above, the pairs and distances would be as follows:

The smallest number in the left list is 1, and the smallest number in the right list is 3. The distance between them is 2.
The second-smallest number in the left list is 2, and the second-smallest number in the right list is another 3. The distance between them is 1.
The third-smallest number in both lists is 3, so the distance between them is 0.
The next numbers to pair up are 3 and 4, a distance of 1.
The fifth-smallest numbers in each list are 3 and 5, a distance of 2.
Finally, the largest number in the left list is 4, while the largest number in the right list is 9; these are a distance 5 apart.
To find the total distance between the left list and the right list, add up the distances between all of the pairs you found. In the example above, this is 2 + 1 + 0 + 1 + 2 + 5, a total distance of 11!

Your actual left and right lists contain many location IDs. What is the total distance between your lists?",
    "Answer": "2378066",
    "Solution": "raw = open("i.txt").readlines()

l = sorted(int(x.split()[0]) for x in raw)
r = sorted(int(x.split()[1]) for x in raw)

print(sum(abs(l[i] - r[i]) for i in range(len(l))))",
    "Language": "python:3.9"
}

Test Cases

The test cases are in the following file structure:

aoc.csv
test_cases/
β”œβ”€β”€ 2024/
β”‚   β”œβ”€β”€ ori_prompt/
β”‚   β”‚   β”œβ”€β”€ day1_part1.txt
β”‚   β”‚   β”œβ”€β”€ day1_part2.txt
β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”‚   └── day25_part1.txt
β”‚   β”œβ”€β”€ test_case1/
β”‚   β”‚   β”œβ”€β”€ answers.csv
β”‚   β”‚   β”œβ”€β”€ day_1_input.txt
β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”‚   └── day_25_input.txt
β”‚   β”œβ”€β”€ test_case2/
β”‚   β”‚   β”œβ”€β”€ answers.csv
β”‚   β”‚   β”œβ”€β”€ day_1_input.txt
β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”‚   └── day_25_input.txt
β”‚   └── test_case3/
β”‚       β”œβ”€β”€ answers.csv
β”‚       β”œβ”€β”€ day_1_input.txt
β”‚       β”œβ”€β”€ ...
β”‚       └── day_25_input.txt

Getting Started

You can access the dataset on Hugging Face using the following commands:

from huggingface_hub import hf_hub_download
import pandas as pd

REPO_ID = "Supa-AI/advent_of_code_ecv_dataset"
FILENAME = "aoc.csv"

dataset = pd.read_csv(
    hf_hub_download(repo_id=REPO_ID, filename=FILENAME, repo_type="dataset")
)

Data Preprocessing

Our software engineering team collects and curates existing solutions from multiple sources, followed by thorough data cleaning and validation to ensure high quality.
The data cleaning involves an automated pipeline that utilizes docker containers to execute the codes and a python script to manage the process as well as to validate the correctness.
For full details on how we cleaned the data, visit our blog post.

Versioning and Maintenance

Current Version: 2.0.0
Release Date: February 07, 2025
Contact: We welcome any feedback or corrections to improve the dataset quality.

How can you contribute?

We welcome contributions that fill gaps in our current dataset, such as data from different years or in additional languages. Feel free to email your solutions to us at developers@supahands.com. Once verified, we will incorporate them into the dataset.

Downloads last month
43