From 7236d5fc0b339082a8048e55d8641aa0ea3a58a7 Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Tue, 13 Dec 2022 16:12:39 +0100 Subject: [PATCH] Try to speed up day 5 --- src/day05.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/day05.rs b/src/day05.rs index c502f3f..6cd1803 100644 --- a/src/day05.rs +++ b/src/day05.rs @@ -48,19 +48,19 @@ pub fn parse(s: &str) -> (Stacks, Vec) { } pub fn apply_moves_by_crate_mover_9000(stacks: &mut Stacks, moves: &[Move]) { - apply_moves(stacks, moves, true); + apply_moves::(stacks, moves); } pub fn apply_moves_by_crate_mover_9001(stacks: &mut Stacks, moves: &[Move]) { - apply_moves(stacks, moves, false); + apply_moves::(stacks, moves); } -fn apply_moves(stacks: &mut Stacks, moves: &[Move], reverse_stack: bool) { +fn apply_moves(stacks: &mut Stacks, moves: &[Move]) { for m in moves { let from = stacks.get_mut(m.from).unwrap(); let mut to_move = from.split_off(from.len() - m.n); - if reverse_stack { + if REVERSE_STACK { to_move.make_contiguous().reverse(); } -- 2.45.2