1use utils::prelude::*;
2
3#[derive(Clone, Debug)]
9pub struct Day12 {
10 part1: usize,
11}
12
13impl Day12 {
14 pub fn new(input: &str, _: InputType) -> Result<Self, InputError> {
15 let part1 = parser::digits_range!(0u32..=99)
16 .repeat_n::<2, _>(b'x')
17 .with_suffix(": ")
18 .then(parser::digits_range!(0u32..=99).repeat_fold(b' ', 1, 0u32, |acc, x| acc + x))
19 .repeat_fold(
20 parser::eol(),
21 1,
22 0usize,
23 |acc, ([width, height], shapes)| {
24 acc + usize::from((width / 3) * (height / 3) >= shapes)
25 },
26 )
27 .with_prefix(
28 parser::digits_range!(0u32..=99)
30 .with_suffix(b':')
31 .with_eol()
32 .then(parser::bitmask_n::<3, u8>(b".#").repeat_n::<3, _>(parser::eol()))
33 .repeat_fold(parser::eol().with_eol(), 1, (), |(), _| ())
34 .with_eol()
35 .with_eol(),
36 )
37 .parse_complete(input)?;
38
39 Ok(Self { part1 })
40 }
41
42 #[must_use]
43 pub fn part1(&self) -> usize {
44 self.part1
45 }
46
47 #[must_use]
48 pub fn part2(&self) -> &'static str {
49 "🎄"
50 }
51}
52
53examples!(Day12 -> (usize, &'static str) []);