Skip to content

Commit

Permalink
Try a silly
Browse files Browse the repository at this point in the history
  • Loading branch information
alion02 committed Dec 6, 2024
1 parent 10f3582 commit 3f77c23
Showing 1 changed file with 37 additions and 41 deletions.
78 changes: 37 additions & 41 deletions src/day6.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use super::*;

#[target_feature(enable = "avx2,bmi1,bmi2,cmpxchg16b,lzcnt,movbe,popcnt")]
#[allow(unreachable_code)]
unsafe fn inner1(s: &[u8]) -> u32 {
let mut loc = s.iter().position(|b| *b == b'^').unwrap_unchecked();
let mut new = [true; 131 * 130];
Expand All @@ -16,46 +15,43 @@ unsafe fn inner1(s: &[u8]) -> u32 {
}
if *s.get_unchecked(next) == b'#' {
loc = loc.wrapping_add(1);
break;
}
loc = next;
}
loop {
total += *new.get_unchecked(loc) as u32;
*new.get_unchecked_mut(loc) = false;
let next = loc.wrapping_add(1);
if *s.get_unchecked(next) == b'\n' {
break 'outer;
}
if *s.get_unchecked(next) == b'#' {
loc = loc.wrapping_add(131);
break;
}
loc = next;
}
loop {
total += *new.get_unchecked(loc) as u32;
*new.get_unchecked_mut(loc) = false;
let next = loc.wrapping_add(131);
if next >= s.len() {
break 'outer;
}
if *s.get_unchecked(next) == b'#' {
loc = loc.wrapping_sub(1);
break;
}
loc = next;
}
loop {
total += *new.get_unchecked(loc) as u32;
*new.get_unchecked_mut(loc) = false;
let next = loc.wrapping_sub(1);
if *s.get_unchecked(next) == b'\n' {
break 'outer;
}
if *s.get_unchecked(next) == b'#' {
loc = loc.wrapping_sub(131);
break;
loop {
total += *new.get_unchecked(loc) as u32;
*new.get_unchecked_mut(loc) = false;
let next = loc.wrapping_add(1);
if *s.get_unchecked(next) == b'\n' {
break 'outer;
}
if *s.get_unchecked(next) == b'#' {
loc = loc.wrapping_add(131);
loop {
total += *new.get_unchecked(loc) as u32;
*new.get_unchecked_mut(loc) = false;
let next = loc.wrapping_add(131);
if next >= s.len() {
break 'outer;
}
if *s.get_unchecked(next) == b'#' {
loc = loc.wrapping_sub(1);
loop {
total += *new.get_unchecked(loc) as u32;
*new.get_unchecked_mut(loc) = false;
let next = loc.wrapping_sub(1);
if *s.get_unchecked(next) == b'\n' {
break 'outer;
}
if *s.get_unchecked(next) == b'#' {
loc = loc.wrapping_sub(131);
continue 'outer;
}
loc = next;
}
}
loc = next;
}
}
loc = next;
}
}
loc = next;
}
Expand Down

0 comments on commit 3f77c23

Please sign in to comment.