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();