Skip to content

Commit

Permalink
README stars
Browse files Browse the repository at this point in the history
  • Loading branch information
BakerNet committed Dec 19, 2023
1 parent 398f40a commit 7a82597
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Solutions for [Advent of Code](https://adventofcode.com/) in [Rust](https://www.
| [Day 16](https://adventofcode.com/2023/day/16) | [code](src/bin/16.rs) |||
| [Day 17](https://adventofcode.com/2023/day/17) | [code](src/bin/17.rs) |||
| [Day 18](https://adventofcode.com/2023/day/18) | [code](src/bin/18.rs) |||
| [Day 19](https://adventofcode.com/2023/day/19) | [code](src/bin/19.rs) | | |
| [Day 19](https://adventofcode.com/2023/day/19) | [code](src/bin/19.rs) | | |
| [Day 20](https://adventofcode.com/2023/day/20) | [code](src/bin/20.rs) | | |
| [Day 21](https://adventofcode.com/2023/day/21) | [code](src/bin/21.rs) | | |
| [Day 22](https://adventofcode.com/2023/day/22) | [code](src/bin/22.rs) | | |
Expand Down
39 changes: 19 additions & 20 deletions src/bin/19.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,26 +178,25 @@ impl PartRanges {

pub fn part_one(input: &str) -> Option<u64> {
let re = Regex::new(r"^([a-zA-Z]+)\{(.+)\}$").unwrap();
let (workflows_map, parts, _): (HashMap<String, Vec<Workflow>>, Vec<Part>, bool) =
input
.lines()
.fold((HashMap::new(), Vec::new(), false), |mut acc, line| {
if line.is_empty() {
acc.2 = true;
return acc;
}
if !acc.2 {
let splits = re
.captures(line)
.unwrap_or_else(|| panic!("Should be able to split workflow {}", line));
let key = &splits[1];
let workflows = splits[2].split(',').map(Workflow::from).collect();
acc.0.insert(key.to_owned(), workflows);
} else {
acc.1.push(Part::from(line));
}
acc
});
let (workflows_map, parts, _): (HashMap<String, Vec<Workflow>>, Vec<Part>, bool) = input
.lines()
.fold((HashMap::new(), Vec::new(), false), |mut acc, line| {
if line.is_empty() {
acc.2 = true;
return acc;
}
if !acc.2 {
let splits = re
.captures(line)
.unwrap_or_else(|| panic!("Should be able to split workflow {}", line));
let key = &splits[1];
let workflows = splits[2].split(',').map(Workflow::from).collect();
acc.0.insert(key.to_owned(), workflows);
} else {
acc.1.push(Part::from(line));
}
acc
});
let mut accepted = Vec::new();
for part in parts.iter() {
let mut curr = String::from("in");
Expand Down

0 comments on commit 7a82597

Please sign in to comment.