From b1d9314bc7da8e254f8202577a3411b6d34403e0 Mon Sep 17 00:00:00 2001 From: Bert Peters Date: Tue, 20 Dec 2022 22:48:17 +0100 Subject: [PATCH] Remove useless code --- 2022/src/day20.rs | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/2022/src/day20.rs b/2022/src/day20.rs index 080acd2..96ada7c 100644 --- a/2022/src/day20.rs +++ b/2022/src/day20.rs @@ -1,5 +1,4 @@ use std::cmp::Ordering; -use std::fmt::Write; use std::iter::once; use anyhow::Context; @@ -15,17 +14,9 @@ fn parse_encrypted(input: &[u8]) -> IResult<&[u8], Vec> { many0(terminated(nom::character::complete::i64, newline))(input) } -fn step(steps: &[usize], mut start: usize, count: usize) -> usize { - for _ in 0..(count % (steps.len() - 1)) { - start = steps[start]; - } - - start -} - // While looping around to find a spot to move to, you must ignore the piece itself, but for // computing the answer, you shouldn't. This function does the latter. -fn step_inclusive(steps: &[usize], mut start: usize, count: usize) -> usize { +fn step(steps: &[usize], mut start: usize, count: usize) -> usize { for _ in 0..(count % steps.len()) { start = steps[start]; } @@ -33,25 +24,6 @@ fn step_inclusive(steps: &[usize], mut start: usize, count: usize) -> usize { start } -#[allow(unused)] -fn print(encrypted: &[i64], next: &[usize]) { - let mut base = String::new(); - - let mut start = 0; - - for _ in 0..encrypted.len() { - if base != "" { - base += ", "; - } - - write!(base, "{}", encrypted[start]).unwrap(); - - start = next[start]; - } - - println!("{base}"); -} - fn move_between(prev: &mut [usize], next: &mut [usize], i: usize, before: usize, after: usize) { if before == i || after == i { return; @@ -126,7 +98,7 @@ fn shuffle(encrypted: &[i64], times: usize) -> Result { let mut sum = 0; for _ in 0..3 { - start = step_inclusive(&next, start, 1000); + start = step(&next, start, 1000); sum += encrypted[start]; }