2 Commits

Author SHA1 Message Date
1dc59c18eb Solve 2025 day 1 part 1 2025-12-01 08:59:13 +01:00
dbcbd15103 Prepare 2025 2025-12-01 08:08:13 +01:00
5 changed files with 46 additions and 43 deletions

View File

@@ -1,43 +0,0 @@
on:
- push
name: Advent of Code 2024
jobs:
ci:
strategy:
matrix:
python-version:
- "3.12"
- "3.13"
name: Continuous Integration
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: "2024/uv.lock"
- name: Check formatting
working-directory: "2024"
run: >
uv run ruff format --check
- name: Run lints
working-directory: "2024"
run: >
uv run ruff check
- name: Run tests
working-directory: "2024"
run: >
uv run pytest tests

5
2025/README.md Normal file
View File

@@ -0,0 +1,5 @@
# Advent of Code 2025
New year, new challenge. With the shorter year, I'm going to try to use a different language every
day, restricting myself to programming languages my employer uses in production. Let's call it the
**Full Stack Challenge**.

10
2025/day01/sample.txt Normal file
View File

@@ -0,0 +1,10 @@
L68
L30
R48
L5
R60
L55
L1
L99
R14
L82

31
2025/day01/solve.nix Normal file
View File

@@ -0,0 +1,31 @@
{
solve = input_file:
let
data = builtins.readFile input_file;
lines = builtins.filter (s: s != "" && builtins.isString s) (builtins.split "\n" data);
mod = a: b: a - (a / b) * b;
recurse = list: position:
let
first = builtins.head list;
# This is not guaranteed to work but it does
num_part = builtins.substring 1 999 first;
num = builtins.fromJSON num_part;
next = if (builtins.substring 0 1 first) == "R"
then
position + num
else
position - num;
new_position = mod ((mod next 100) + 100) 100;
score = if new_position == 0 then 1 else 0;
in
if list == [] then
0
else
score + (recurse (builtins.tail list) new_position);
in
recurse lines 50;
}

0
2025/inputs/.gitkeep Normal file
View File