2022 day9/rust: rename some items for clarity
This commit is contained in:
parent
d627f1d00f
commit
e1862bdcbb
1 changed files with 4 additions and 4 deletions
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue