mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 21:00:31 +01:00
Compare commits
2 Commits
b6aafa1b27
...
1dc59c18eb
| Author | SHA1 | Date | |
|---|---|---|---|
| 1dc59c18eb | |||
| dbcbd15103 |
43
.github/workflows/2024.yml
vendored
43
.github/workflows/2024.yml
vendored
@@ -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
5
2025/README.md
Normal 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
10
2025/day01/sample.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
L68
|
||||
L30
|
||||
R48
|
||||
L5
|
||||
R60
|
||||
L55
|
||||
L1
|
||||
L99
|
||||
R14
|
||||
L82
|
||||
31
2025/day01/solve.nix
Normal file
31
2025/day01/solve.nix
Normal 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
0
2025/inputs/.gitkeep
Normal file
Reference in New Issue
Block a user