We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 824d343 commit ad36989Copy full SHA for ad36989
crates/year2024/src/day25.rs
@@ -7,12 +7,20 @@ pub struct Day25 {
7
keys: Vec<u32>,
8
}
9
10
+const LOOKUP: [Option<bool>; 256] = {
11
+ let mut x = [None; 256];
12
+ x['#' as usize] = Some(true);
13
+ x['.' as usize] = Some(false);
14
+ x
15
+};
16
+
17
impl Day25 {
18
pub fn new(input: &str, _: InputType) -> Result<Self, InputError> {
19
let mut locks = Vec::with_capacity(250);
20
let mut keys = Vec::with_capacity(250);
21
- for item in parser::one_of((b'.'.map(|_| false), b'#'.map(|_| true)))
22
+ for item in parser::byte()
23
+ .map_res(|b| LOOKUP[b as usize].ok_or("expected '.' or '#'"))
24
.repeat_n::<5, _>(parser::noop())
25
.repeat_n::<7, _>(parser::eol())
26
.with_consumed()
0 commit comments