Day 21 part 2 working.
This commit is contained in:
parent
9ef8a73b15
commit
97d32e2588
@ -166,12 +166,12 @@ fn allergen_ingredients(foods: &[Food], non_allergens: &HashSet<String>) -> Vec<
|
|||||||
// allergen/ingredient combo. Then remove that ingredient from all the other entries, and
|
// allergen/ingredient combo. Then remove that ingredient from all the other entries, and
|
||||||
// repeat until nothing is left.
|
// repeat until nothing is left.
|
||||||
dbg!(&allergen_only);
|
dbg!(&allergen_only);
|
||||||
let mut answer = Vec::new();
|
let mut answer = HashMap::new();
|
||||||
let mut limit = 0;
|
let mut limit = 0;
|
||||||
loop {
|
loop {
|
||||||
dbg!(&allergen_only);
|
dbg!(&allergen_only);
|
||||||
if allergen_only.is_empty() {
|
if allergen_only.is_empty() {
|
||||||
return answer;
|
return answer.into_iter().collect();
|
||||||
};
|
};
|
||||||
let mut rm = ("".to_string(), "".to_string());
|
let mut rm = ("".to_string(), "".to_string());
|
||||||
allergen_only.iter().for_each(|(a, i_counts)| {
|
allergen_only.iter().for_each(|(a, i_counts)| {
|
||||||
@ -183,7 +183,7 @@ fn allergen_ingredients(foods: &[Food], non_allergens: &HashSet<String>) -> Vec<
|
|||||||
.map(|(i, _c)| i)
|
.map(|(i, _c)| i)
|
||||||
.nth(0)
|
.nth(0)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
answer.push((a.to_string(), i.to_string()));
|
answer.insert(a.to_string(), i.to_string());
|
||||||
rm = (a.to_string(), i.to_string());
|
rm = (a.to_string(), i.to_string());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user