Skip to content

Commit ab0931c

Browse files
authored
Factor out a multiplication
1 parent 9c3b8ef commit ab0931c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/year2022/day20.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ fn decrypt(input: &[i64], key: i64, rounds: usize) -> i64 {
109109
let indices: Vec<_> = mixed.into_iter().flatten().flatten().collect();
110110
let zeroth = indices.iter().position(|&i| numbers[i] == 0).unwrap();
111111

112-
[1000, 2000, 3000]
112+
key * [1000, 2000, 3000]
113113
.iter()
114114
.map(|offset| (zeroth + offset) % indices.len())
115-
.map(|index| input[indices[index]] * key)
116-
.sum()
115+
.map(|index| input[indices[index]])
116+
.sum::<i64>()
117117
}

0 commit comments

Comments
 (0)