This commit is contained in:
2025-12-02 13:07:37 -08:00
parent d229bb7889
commit 0f2024c474
4 changed files with 19 additions and 10 deletions

View File

@@ -1,6 +1,4 @@
use aoc_runner_derive::aoc;
use std::io::{BufRead, BufReader, Lines};
use std::time::{Duration, Instant};
// PROBLEM 1 solution
#[aoc(day1, part1)]
@@ -16,7 +14,7 @@ pub fn part1(input: &str) -> u64 {
let add_val = match sign.as_bytes()[0] {
b'R' => num_val,
b'L' => mod_val - (num_val % mod_val),
c => panic!("Invalid direction {}", c),
c => panic!("Invalid direction {c}"),
};
val = (val + add_val) % mod_val;
if val == 0 {
@@ -65,7 +63,7 @@ pub fn part2(input: &str) -> i64 {
let (new_val, add_pass) = match sign.as_bytes()[0] {
b'R' => advance::<100>(val, num_val),
b'L' => advance::<100>(val, -num_val),
c => panic!("Invalid direction {}", c),
c => panic!("Invalid direction {c}"),
};
val = new_val;
pass += add_pass;
@@ -77,7 +75,7 @@ pub fn part2(input: &str) -> i64 {
mod tests {
use crate::day1::*;
const EXAMPLE: &str = &"L68
const EXAMPLE: &str = "L68
L30
R48
L5