Skip to content

Commit 4b83b94

Browse files
committed
simple cleanup
1 parent 11d6f7b commit 4b83b94

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

src/bin/10.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ fn part_x(grid: &Grid<u8>) -> FastMap<(Point, Point), u32> {
2828
continue;
2929
}
3030

31-
for step in [LEFT, RIGHT, UP, DOWN] {
32-
let next_location = location + step;
31+
for next_location in ORTHOGONAL.map(|o| location + o) {
3332
if grid.contains(next_location) && grid[next_location] == height + 1 {
3433
paths.push((height + 1, next_location));
3534
}

src/bin/16.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn neighbors(
1717
) -> Vec<(Point, Point, u32)> {
1818
let mut result = Vec::with_capacity(4);
1919

20-
for n_direction in [LEFT, RIGHT, UP, DOWN] {
20+
for n_direction in ORTHOGONAL {
2121
let n_position = position + n_direction;
2222

2323
if grid[n_position] != b'#' {
@@ -42,7 +42,7 @@ fn neighbors(
4242
(DOWN, RIGHT) => 1001,
4343
(DOWN, UP) => 2001,
4444

45-
_ => panic!("Invalid state"),
45+
_ => unreachable!(),
4646
};
4747

4848
result.push((n_position, n_direction, cost + n_cost_diff));

src/bin/17.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn run_program(a: u64) -> Vec<u8> {
1414
let mut a = a;
1515
while a > 0 {
1616
let b = (a ^ 1) & 7;
17-
result.push((((b ^ (a >> b)) ^ 4) & 7) as u8);
17+
result.push((b ^ 4 ^ (a >> b) & 7) as u8);
1818

1919
a >>= 3;
2020
}

0 commit comments

Comments
 (0)