Skip to content

Commit 485f30c

Browse files
committed
Revert "Early exit in part 1"
This reverts commit 1b5a30a.
1 parent 1b5a30a commit 485f30c

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/day10.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ unsafe fn part1_inner(s: &str) -> u32 {
4343
let mut current = &mut [0u64; MAX_SIZE + 2];
4444

4545
let mut sum = 0;
46-
'outer: for (x, y) in &zeros[..zeros_i] {
46+
for (x, y) in &zeros[..zeros_i] {
4747
current[*y + 1] |= 1 << *x;
4848
for layer in 0..9 {
4949
// for yp1 in 1..size + 1 {
@@ -59,21 +59,16 @@ unsafe fn part1_inner(s: &str) -> u32 {
5959
// }
6060
// println!("");
6161

62-
let mut any = 0;
6362
for yp1 in 1..size + 1 {
6463
let to_left = (current[yp1] << 1) & maps[layer][yp1];
6564
let to_right = (current[yp1] >> 1) & maps[layer][yp1];
6665
let to_down = current[yp1 - 1] & maps[layer][yp1];
6766
let to_up = current[yp1 + 1] & maps[layer][yp1];
6867

69-
let total = to_left | to_right | to_down | to_up;
70-
any |= total;
71-
next[yp1] = total;
72-
}
73-
if any == 0 {
74-
next.fill(0);
75-
current.fill(0);
76-
continue 'outer;
68+
let to_left_and_right = to_left | to_right;
69+
let to_left_down_and_right = to_left_and_right | to_down;
70+
71+
next[yp1] = to_left_down_and_right | to_up;
7772
}
7873

7974
std::mem::swap(&mut current, &mut next);

0 commit comments

Comments
 (0)