Skip to content

Commit 93488fe

Browse files
committed
Store full data
1 parent 2cd3f2e commit 93488fe

File tree

1 file changed

+6
-22
lines changed

1 file changed

+6
-22
lines changed

src/day25.rs

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ const DS: usize = 7 * 6 + 1;
1919
unsafe fn part1_inner(s: &[u8]) -> u64 {
2020
let mut sum = 0;
2121

22-
let mut keys = heapless::Vec::<u16, 512>::new();
23-
let mut holes = heapless::Vec::<u16, 512>::new();
22+
let mut keys = heapless::Vec::<__m256i, 512>::new();
23+
let mut holes = heapless::Vec::<__m256i, 512>::new();
2424

2525
for i in 0..SIZE {
2626
let i = i * DS;
@@ -43,35 +43,19 @@ unsafe fn part1_inner(s: &[u8]) -> u64 {
4343
);
4444

4545
let other = if is_key { &holes } else { &keys };
46-
for other_i in other {
47-
let o = s
48-
.as_ptr()
49-
.offset(*other_i as isize + 6)
50-
.cast::<__m256i>()
51-
.read_unaligned();
52-
let o = _mm256_and_si256(
53-
o,
54-
_mm256_setr_epi8(
55-
-1, -1, -1, -1, -1, 0, //
56-
-1, -1, -1, -1, -1, 0, //
57-
-1, -1, -1, -1, -1, 0, //
58-
-1, -1, -1, -1, -1, 0, //
59-
-1, -1, -1, -1, -1, 0, 0, 0,
60-
),
61-
);
62-
46+
for o in other {
6347
let collisions = _mm256_cmpeq_epi8(
64-
_mm256_add_epi8(d, o),
48+
_mm256_add_epi8(d, *o),
6549
_mm256_set1_epi8(b'#'.wrapping_add(b'#') as i8),
6650
);
6751
let collisions = _mm256_movemask_epi8(collisions);
6852
sum += (collisions == 0) as u64;
6953
}
7054

7155
if is_key {
72-
keys.push_unchecked(i as u16);
56+
keys.push_unchecked(d);
7357
} else {
74-
holes.push_unchecked(i as u16);
58+
holes.push_unchecked(d);
7559
}
7660
}
7761

0 commit comments

Comments
 (0)