cargo fmt
parent
14b0294282
commit
408a690061
|
@ -1,6 +1,6 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use std::fs;
|
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
use std::fs;
|
||||||
|
|
||||||
fn get_priority(t: &char) -> u32 {
|
fn get_priority(t: &char) -> u32 {
|
||||||
if t.is_ascii_uppercase() {
|
if t.is_ascii_uppercase() {
|
||||||
|
@ -47,14 +47,20 @@ pub fn run() -> Result<()> {
|
||||||
let elf2map: HashSet<char> = HashSet::from_iter(elf2.chars());
|
let elf2map: HashSet<char> = HashSet::from_iter(elf2.chars());
|
||||||
let elf3map: HashSet<char> = HashSet::from_iter(elf3.chars());
|
let elf3map: HashSet<char> = HashSet::from_iter(elf3.chars());
|
||||||
|
|
||||||
for dupe in elf1map.iter().filter(|t| elf2map.contains(t) && elf3map.contains(t)) {
|
for dupe in elf1map
|
||||||
|
.iter()
|
||||||
|
.filter(|t| elf2map.contains(t) && elf3map.contains(t))
|
||||||
|
{
|
||||||
rucksacks2.push(get_priority(dupe));
|
rucksacks2.push(get_priority(dupe));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
println!("part two priorities {}", rucksacks2.into_iter().sum::<u32>());
|
println!(
|
||||||
|
"part two priorities {}",
|
||||||
|
rucksacks2.into_iter().sum::<u32>()
|
||||||
|
);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue