Day 15, small cleanup

This commit is contained in:
Daniel S. 2020-12-16 20:13:13 +01:00
parent e9e7478fe2
commit ce55569030

View file

@ -49,8 +49,7 @@ fn get_number(start: &[usize], num_turns: usize) -> usize {
let mut nums = start.to_vec(); let mut nums = start.to_vec();
let mut num=std::usize::MAX; let mut num=std::usize::MAX;
for i in 1..num_turns { for i in 1..num_turns {
let e = cache.entry(nums[i - 1]).or_default(); num = cache.entry(nums[i - 1]).or_default().add(i);
num=e.add(i);
if i >= nums.len() { if i >= nums.len() {
nums.push(num); nums.push(num);
} }