Compare commits

..

1 Commits

Author SHA1 Message Date
19d9d47d4f Day 8 part 2 2021-12-07 22:46:43 -08:00

View File

@ -156,13 +156,10 @@ fn build_lookup(input: &str) -> Result<HashMap<String, &str>> {
let one: HashSet<_> = map["1"].chars().collect();
let four: HashSet<_> = map["4"].chars().collect();
//let seven_int: HashSet<_> = s.intersection(&seven).cloned().collect();
//let eight_int: HashSet<_> = s.intersection(&eight).cloned().collect();
// 0, 6 or 9 have 6 segments:
// 0 is missing an intersection w/ 4
// 6 is missing an intersection w/ 1
// 9 is the left overs.
// 9 contains 1 and 4
// 0 intersects w/ 1 but not w/ 4
// 6 is the left overs.
set.iter().filter(|s| s.len() == 6).for_each(|d| {
let s: HashSet<_> = d.chars().collect();
let one_int: HashSet<_> = s.intersection(&one).cloned().collect();
@ -211,6 +208,7 @@ fn output(line: &str) -> Result<u64> {
Ok(out
.split(' ')
.map(|s| {
// Sort letters in string before looking up.
let mut s: Vec<_> = s.chars().collect();
s.sort_unstable();
let s: String = s.iter().collect();