remove editor warning for import

This commit is contained in:
Adam Jeniski 2022-12-04 16:13:07 -05:00
parent b90734ce25
commit 375e2fb1c3

View File

@ -1,5 +1,3 @@
use std::collections::HashSet;
fn get_priority(c: char) -> i32 { fn get_priority(c: char) -> i32 {
match c { match c {
'a'..='z' => c as i32 - 'a' as i32 + 1, 'a'..='z' => c as i32 - 'a' as i32 + 1,
@ -16,6 +14,7 @@ advent_of_code_macro::solve_problem!(
}, },
part one |data: Input| { part one |data: Input| {
data.iter().map(|s| { data.iter().map(|s| {
use std::collections::HashSet;
let (left, right) = s.split_at(s.len() / 2); let (left, right) = s.split_at(s.len() / 2);
let right_set: HashSet<char> = right.chars().collect(); let right_set: HashSet<char> = right.chars().collect();
get_priority(left.chars().find(|c| right_set.contains(c)).unwrap()) get_priority(left.chars().find(|c| right_set.contains(c)).unwrap())
@ -23,6 +22,7 @@ advent_of_code_macro::solve_problem!(
}, },
part two |data: Input| { part two |data: Input| {
data.as_slice().chunks(3).map(|c| { data.as_slice().chunks(3).map(|c| {
use std::collections::HashSet;
let second_set: HashSet<char> = c[1].chars().collect(); let second_set: HashSet<char> = c[1].chars().collect();
let third_set: HashSet<char> = c[2].chars().collect(); let third_set: HashSet<char> = c[2].chars().collect();
get_priority(c[0].chars().find(|c| second_set.contains(c) && third_set.contains(c)).unwrap()) get_priority(c[0].chars().find(|c| second_set.contains(c) && third_set.contains(c)).unwrap())