diff options
author | Justin Wernick <justin@worthe-it.co.za> | 2023-12-19 23:31:25 +0200 |
---|---|---|
committer | Justin Wernick <justin@worthe-it.co.za> | 2023-12-19 23:31:25 +0200 |
commit | ab61f564fd174e19c74b6ff8be2e9611fb178ba6 (patch) | |
tree | d4731e0634e08e69baee62a2598abc9c82708be7 /2023/src/bin | |
parent | a2ce5eb7f720d17aac648a5b3fd8e97df198803c (diff) |
Day 19 filling in the types for part 1
Diffstat (limited to '2023/src/bin')
-rw-r--r-- | 2023/src/bin/day_19.rs | 58 |
1 files changed, 52 insertions, 6 deletions
diff --git a/2023/src/bin/day_19.rs b/2023/src/bin/day_19.rs index b3a610b..fd25a5d 100644 --- a/2023/src/bin/day_19.rs +++ b/2023/src/bin/day_19.rs @@ -1,19 +1,65 @@ use nom::IResult; -use std::fs; +use std::{collections::BTreeMap, fs}; fn main() -> Result<(), Box<dyn std::error::Error>> { - let input = fs::read_to_string("inputs/day_2.txt")?; - let parsed = Example::parser(&input).unwrap().1; + let input = fs::read_to_string("inputs/day_19.txt")?; + let parsed = PartSortingMess::parser(&input).unwrap().1; dbg!(&parsed); Ok(()) } #[derive(Debug)] -struct Example; +struct PartSortingMess { + workflows: BTreeMap<String, Workflow>, + parts: Vec<Part>, +} + +#[derive(Debug)] +struct Workflow { + id: String, + conditions: WorkflowStep, + if_none_match: WorkflowOutcome, +} + +#[derive(Debug)] +struct WorkflowStep { + field: PartField, + condition: WorkflowCondition, + result: WorkflowOutcome, +} + +#[derive(Debug)] +enum PartField { + X, + M, + A, + S, +} + +#[derive(Debug)] +enum WorkflowCondition { + LessThan(u32), + GreaterThan(u32), +} + +#[derive(Debug)] +enum WorkflowOutcome { + Accept, + Reject, + Defer(String), +} + +#[derive(Debug)] +struct Part { + x: u32, + m: u32, + a: u32, + s: u32, +} -impl Example { - fn parser(_input: &str) -> IResult<&str, Self> { +impl PartSortingMess { + fn parser(input: &str) -> IResult<&str, Self> { todo!() } } |