Skip to content

Commit

Permalink
why
Browse files Browse the repository at this point in the history
  • Loading branch information
Icerath committed Dec 16, 2024
1 parent a03dc22 commit 64cdb16
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/day15.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#![allow(clippy::cast_possible_truncation)]

use std::{
hint::unreachable_unchecked,
simd::{cmp::SimdPartialEq, u8x64, Simd},
};
use std::hint::unreachable_unchecked;

use bstr::ByteSlice;

Expand Down Expand Up @@ -39,14 +36,11 @@ unsafe fn part1_inner(input: &[u8]) -> usize {
i += 1;
}
let mut result = 0;
for i in 0..50 {
let line = u8x64::load_or_default(grid.get_unchecked(i * 51..));
let mut mask = line.simd_eq(Simd::splat(b'O')).to_bitmask();
mask &= (1 << 50) - 1;
while mask > 0 {
let j = mask.trailing_zeros() as usize;
result += 100 * i + j;
mask &= mask - 1;
for j in 0..50 {
for i in 0..50 {
if grid[j + i * 51] == b'O' {
result += 100 * i + j;
}
}
}
result
Expand Down

0 comments on commit 64cdb16

Please sign in to comment.