This commit is contained in:
nora 2023-12-02 22:01:39 +01:00
parent 267b9e8c3d
commit d5b8c4ed21
3 changed files with 155 additions and 1 deletions

View file

@ -14,7 +14,12 @@ pub unsafe fn part2(input: &str) {
// in the integer bytes:
// X X X X X e n o
// this out of bounds read is UB under SB, but fine under models that don't do provenance narrowing with slices. i dont care enough to fix it.
let block = bytes.as_ptr().add(byte_idx).cast::<u64>().read_unaligned().to_le();
let block = bytes
.as_ptr()
.add(byte_idx)
.cast::<u64>()
.read_unaligned()
.to_le();
let one = (block & ((1 << (8 * 1)) - 1)) as u8;
let three = block & ((1 << (8 * 3)) - 1);