simplify priority math
This commit is contained in:
parent
894ddd8ca7
commit
fc2099c14c
14
03/main.rs
14
03/main.rs
@ -43,11 +43,7 @@ fn part_one() {
|
||||
}
|
||||
for item in pocket_two.chars() {
|
||||
if knapsack.contains_key(&item) {
|
||||
if item as u32 > 96 {
|
||||
priorities += item as u32 - 96
|
||||
} else {
|
||||
priorities += item as u32 - 38
|
||||
}
|
||||
priorities += (item as u32 - 38) % 58;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -78,12 +74,8 @@ fn part_two() {
|
||||
HashSet::from_iter(one.intersection(three));
|
||||
let mut result = intermediate_one.intersection(&intermediate_two);
|
||||
if let Some(item) = result.next() {
|
||||
// double pointers!
|
||||
if **item as u32 > 96 {
|
||||
priorities += **item as u32 - 96
|
||||
} else {
|
||||
priorities += **item as u32 - 38
|
||||
}
|
||||
// double pointer!
|
||||
priorities += (**item as u32 - 38) % 58;
|
||||
}
|
||||
}
|
||||
group.clear();
|
||||
|
Loading…
Reference in New Issue
Block a user