1
0
This commit is contained in:
2022-12-27 01:46:31 +00:00
parent 8fbaaa4bbc
commit e871837dc6
11 changed files with 110 additions and 86 deletions

View File

@ -13,7 +13,7 @@ const ZERO: IVec2 = IVec2::new(0, 0);
fn main() {
const INPUT: &str = include_str!("../input.txt");
let mut visited: HashSet<IVec2> = HashSet::new();
let mut knots: [IVec2; 10] = [ZERO; 10];
@ -25,7 +25,7 @@ fn main() {
'L' => LEFT,
'U' => UP,
'D' => DOWN,
_ => ZERO,
_ => ZERO,
};
let steps: u32 = steps.parse().unwrap();
@ -46,7 +46,7 @@ fn main() {
if diff.x == 0 {
knot.y += diff.y.signum();
} else if diff.y == 0 {
knot.x += diff.x.signum();
knot.x += diff.x.signum();
} else {
knot.x += diff.x.signum();
knot.y += diff.y.signum();