Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit feeb6df

Browse files
committedDec 25, 2020
Day 25 rust
1 parent a591783 commit feeb6df

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed
 

‎data/day25.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
8987316
2+
14681524

‎src/days/day25.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use anyhow::Result;
2+
use libaoc::{aoc, AocResult, Timer};
3+
4+
fn trans(subject: usize, loop_size: usize) -> usize {
5+
let mut value = 1;
6+
for _ in 0..loop_size {
7+
value *= subject;
8+
value %= 20201227;
9+
}
10+
value
11+
}
12+
13+
#[aoc("15217943", "")]
14+
pub fn solve(timer: &mut Timer, input: &str) -> Result<AocResult> {
15+
let input: Vec<usize> = input.lines().map(|x|x.parse().unwrap()).collect();
16+
timer.lap("Parse");
17+
18+
let mut card_loop = 0;
19+
let mut value = 1;
20+
while value != input[0] {
21+
value *= 7;
22+
value %= 20201227;
23+
card_loop += 1;
24+
}
25+
26+
let part1 = trans(input[1], card_loop);
27+
28+
29+
timer.lap("Part 1");
30+
31+
32+
timer.lap("Part 2");
33+
34+
Ok(AocResult::new(part1, ""))
35+
}

‎src/days/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ mod day21;
2222
mod day22;
2323
mod day23;
2424
mod day24;
25+
mod day25;

0 commit comments

Comments
 (0)
Please sign in to comment.