day 25
This commit is contained in:
42
src/day25.rs
42
src/day25.rs
@@ -1,18 +1,42 @@
|
||||
use aoc_runner_derive::{aoc, aoc_generator};
|
||||
|
||||
type Input = ();
|
||||
type Input = (u64, u64);
|
||||
|
||||
#[aoc_generator(day22)]
|
||||
#[aoc_generator(day25)]
|
||||
fn parse(input: &str) -> Input {
|
||||
todo!()
|
||||
let parts: Vec<&str> = input.split_whitespace().collect();
|
||||
let row = parts[15].trim_end_matches(",").parse().unwrap();
|
||||
let column = parts[17].trim_end_matches(".").parse().unwrap();
|
||||
|
||||
(column, row)
|
||||
}
|
||||
|
||||
#[aoc(day22, part1)]
|
||||
fn part1(_: &Input) -> usize {
|
||||
0
|
||||
#[aoc(day25, part1)]
|
||||
fn part1((col, row): &Input) -> u64 {
|
||||
let diagonals_before = (col - 1) + (row - 1);
|
||||
let entries_in_full_diags = (diagonals_before * diagonals_before + diagonals_before) / 2;
|
||||
let target_diag_before = col - 1;
|
||||
|
||||
let entries_before_code = entries_in_full_diags + target_diag_before;
|
||||
let mut val = 20151125;
|
||||
for _ in 1..=entries_before_code {
|
||||
val *= 252533;
|
||||
val %= 33554393;
|
||||
}
|
||||
val
|
||||
}
|
||||
|
||||
#[aoc(day22, part2)]
|
||||
fn part2(_: &Input) -> usize {
|
||||
0
|
||||
#[aoc(day25, part2)]
|
||||
fn part2(_: &Input) -> &'static str {
|
||||
"---"
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::day25::part1;
|
||||
|
||||
#[test]
|
||||
fn foo() {
|
||||
assert_eq!(21345942, part1(&(3, 4)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,5 +17,6 @@ mod day21;
|
||||
mod day22;
|
||||
mod day23;
|
||||
mod day24;
|
||||
mod day25;
|
||||
|
||||
aoc_lib! { year = 2015 }
|
||||
|
||||
Reference in New Issue
Block a user