diff --git a/2025/inputs/01.txt b/2025/inputs/01.txt deleted file mode 100644 index 53287c7..0000000 --- a/2025/inputs/01.txt +++ /dev/null @@ -1,10 +0,0 @@ -L68 -L30 -R48 -L5 -R60 -L55 -L1 -L99 -R14 -L82 diff --git a/2025/rust/.envrc b/2025/rust/.envrc deleted file mode 100644 index 4196168..0000000 --- a/2025/rust/.envrc +++ /dev/null @@ -1 +0,0 @@ -use flake .#rust diff --git a/2025/rust/day-01/Cargo.lock b/2025/rust/day-01/Cargo.lock deleted file mode 100644 index 6e11d14..0000000 --- a/2025/rust/day-01/Cargo.lock +++ /dev/null @@ -1,7 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 4 - -[[package]] -name = "day-01" -version = "0.1.0" diff --git a/2025/rust/day-01/Cargo.toml b/2025/rust/day-01/Cargo.toml deleted file mode 100644 index c43f1c8..0000000 --- a/2025/rust/day-01/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "day-01" -version = "0.1.0" -edition = "2024" - -[dependencies] diff --git a/2025/rust/day-01/src/main.rs b/2025/rust/day-01/src/main.rs deleted file mode 100644 index d8a8346..0000000 --- a/2025/rust/day-01/src/main.rs +++ /dev/null @@ -1,62 +0,0 @@ -use std::fs::{self}; - -const STARTING_POSITION: i32 = 50; -const DIAL_RANGE: i32 = 100; - -fn main() { - let rotations = read_rotations(); - - println!("Password1: {}", count_zero_positions(&rotations)); - println!("Password2: {}", count_zero_clicks(&rotations)); -} - -fn read_rotations() -> Vec { - fs::read_to_string("../../inputs/01.txt") - .unwrap() - .lines() - .map(|line| { - let distance = line[1..].parse::().unwrap(); - if line.starts_with('L') { - -distance - } else { - distance - } - }) - .collect() -} - -fn count_zero_positions(rotations: &[i32]) -> i32 { - let mut counter = 0; - let mut position = STARTING_POSITION; - - for rotation in rotations { - position = (position + rotation).rem_euclid(DIAL_RANGE); - - if position == 0 { - counter += 1; - } - } - - counter -} - -fn count_zero_clicks(rotations: &[i32]) -> i32 { - let mut counter = 0; - let mut position = STARTING_POSITION; - - for rotation in rotations { - position += rotation; - - counter += (position / DIAL_RANGE).abs(); - if position < 0 && position != *rotation { - counter += 1; - } - if position == 0 { - counter += 1; - } - - position = position.rem_euclid(DIAL_RANGE); - } - - counter -} diff --git a/flake.lock b/flake.lock index b86cd41..a4ac182 100644 --- a/flake.lock +++ b/flake.lock @@ -2,16 +2,16 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1764522689, - "narHash": "sha256-SqUuBFjhl/kpDiVaKLQBoD8TLD+/cTUzzgVFoaHrkqY=", + "lastModified": 1759439645, + "narHash": "sha256-oiAyQaRilPk525Z5aTtTNWNzSrcdJ7IXM0/PL3CGlbI=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "8bb5646e0bed5dbd3ab08c7a7cc15b75ab4e1d0f", + "rev": "879bd460b3d3e8571354ce172128fbcbac1ed633", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-25.11", + "ref": "nixos-25.05", "repo": "nixpkgs", "type": "github" } @@ -29,11 +29,11 @@ ] }, "locked": { - "lastModified": 1764557621, - "narHash": "sha256-kX5PoY8hQZ80+amMQgOO9t8Tc1JZ70gYRnzaVD4AA+o=", + "lastModified": 1759544920, + "narHash": "sha256-yQwP0JOHi3Icq09GG5ufGuGrq2zIijglVFj3kkF2MHA=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "93316876c2229460a5d6f5f052766cc4cef538ce", + "rev": "bd3a63bbff2c4cb3cd48e9d49f54c2ccad457f70", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 27280c3..40dd6bf 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,6 @@ { inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05"; rust-overlay = { url = "github:oxalica/rust-overlay"; @@ -20,6 +20,7 @@ packages = with pkgs; [ gdb clang-tools + qt6.full ]; };