From e1862bdcbb5ccb7314751e15d79594bb7740a45f Mon Sep 17 00:00:00 2001 From: Xiretza Date: Fri, 9 Dec 2022 16:19:29 +0100 Subject: [PATCH] 2022 day9/rust: rename some items for clarity --- 2022/day9/rust/src/main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/2022/day9/rust/src/main.rs b/2022/day9/rust/src/main.rs index e7f6551..5d4273d 100644 --- a/2022/day9/rust/src/main.rs +++ b/2022/day9/rust/src/main.rs @@ -7,8 +7,8 @@ use std::{ use aoc::vec2::{Direction, Vec2}; -fn tail_movement(following: Vec2, tail: Vec2) -> Vec2 { - let (dx, dy) = (following - tail).into(); +fn knot_movement(previous: Vec2, knot: Vec2) -> Vec2 { + let (dx, dy) = (previous - knot).into(); let movement = if dx.abs() <= 1 && dy.abs() <= 1 { (0, 0) @@ -33,8 +33,8 @@ fn simulate_knots(num_knots: usize, instructions: &[(Direction, usize)]) -> usiz let tail = knots .iter_mut() - .reduce(|following, knot| { - *knot += tail_movement(*following, *knot); + .reduce(|previous, knot| { + *knot += knot_movement(*previous, *knot); knot }) .unwrap();