Compare commits
1 Commits
bb74658f9c
...
19d9d47d4f
| Author | SHA1 | Date | |
|---|---|---|---|
| 19d9d47d4f |
@ -156,13 +156,10 @@ fn build_lookup(input: &str) -> Result<HashMap<String, &str>> {
|
|||||||
let one: HashSet<_> = map["1"].chars().collect();
|
let one: HashSet<_> = map["1"].chars().collect();
|
||||||
let four: HashSet<_> = map["4"].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, 6 or 9 have 6 segments:
|
||||||
// 0 is missing an intersection w/ 4
|
// 9 contains 1 and 4
|
||||||
// 6 is missing an intersection w/ 1
|
// 0 intersects w/ 1 but not w/ 4
|
||||||
// 9 is the left overs.
|
// 6 is the left overs.
|
||||||
set.iter().filter(|s| s.len() == 6).for_each(|d| {
|
set.iter().filter(|s| s.len() == 6).for_each(|d| {
|
||||||
let s: HashSet<_> = d.chars().collect();
|
let s: HashSet<_> = d.chars().collect();
|
||||||
let one_int: HashSet<_> = s.intersection(&one).cloned().collect();
|
let one_int: HashSet<_> = s.intersection(&one).cloned().collect();
|
||||||
@ -211,6 +208,7 @@ fn output(line: &str) -> Result<u64> {
|
|||||||
Ok(out
|
Ok(out
|
||||||
.split(' ')
|
.split(' ')
|
||||||
.map(|s| {
|
.map(|s| {
|
||||||
|
// Sort letters in string before looking up.
|
||||||
let mut s: Vec<_> = s.chars().collect();
|
let mut s: Vec<_> = s.chars().collect();
|
||||||
s.sort_unstable();
|
s.sort_unstable();
|
||||||
let s: String = s.iter().collect();
|
let s: String = s.iter().collect();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user