From bce1acab9034b1b9af4de804839c70b9552f5078 Mon Sep 17 00:00:00 2001 From: Dorje Gilfillan Date: Mon, 16 Dec 2024 17:48:45 +0200 Subject: [PATCH] just be boring --- src/day15.rs | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/day15.rs b/src/day15.rs index 924e76d..1eebf32 100644 --- a/src/day15.rs +++ b/src/day15.rs @@ -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; @@ -38,18 +35,7 @@ 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; - } - } - result + grid.find_iter(b"O").map(|pos| 100 * (pos / 51) + pos % 51).sum() } pub fn part2(input: &str) -> usize {