Skip to content

Commit

Permalink
day19
Browse files Browse the repository at this point in the history
  • Loading branch information
vslinko committed Dec 19, 2024
1 parent a95f7d4 commit fcab51d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/day19.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashMap;

use rayon::prelude::*;
use rustc_hash::{FxBuildHasher, FxHashMap, FxHashSet};
use std::collections::HashMap;

pub fn part1(input: &str) -> usize {
unsafe { inner1(input) }
Expand All @@ -24,7 +24,7 @@ unsafe fn inner1(input: &str) -> usize {
let designs: Vec<&str> = lines.collect();

designs
.iter()
.par_iter()
.filter(|design| can_make_design(design, &patterns_by_length))
.count()
}
Expand All @@ -44,20 +44,20 @@ fn can_make_design_recursive(
}

for (&length, patterns) in patterns_by_length.iter() {
if pos + length > design.len() {
let next_pos = pos + length;

if next_pos > design.len() {
continue;
}

'pattern_loop: for pattern in patterns {
let pattern_bytes = pattern.as_bytes();

for (j, &pattern_byte) in pattern_bytes.iter().enumerate() {
for (j, &pattern_byte) in pattern.as_bytes().iter().enumerate() {
if design[pos + j] != pattern_byte {
continue 'pattern_loop;
}
}

if can_make_design_recursive(pos + length, design, patterns_by_length, memo) {
if can_make_design_recursive(next_pos, design, patterns_by_length, memo) {
return true;
}
}
Expand Down

0 comments on commit fcab51d

Please sign in to comment.