Skip to content
CodeItRaw
Code Reading
/
Sliding Window
Path
Play
Daily
Leaderboard
tr
Bug Hunt
Sliding Window
It should return the sum of every run of k neighbours: [1, 2, 3, 4] with k = 2 gives [3, 5, 7]. One window goes missing. Find the line and the kind of bug.
Click the line you think is wrong.
1
def
window_sums
(values, k):
2
sums = []
3
for
i
in
range
(
len
(values) - k):
4
sums.append(
sum
(values[i:i + k]))
5
return
sums