Skip to content
DeepForgeby svx
All problems
EasyTime Seriests-190

Temporal Hierarchy Aggregation

Problem

Aggregate a series at several temporal scales. For each scale k in scales, sum each complete group of k consecutive values and drop the trailing partial group.

Return a list with one list of sums per scale, in the same order as scales.

Hint

Scale 1 reproduces the original series as one-element sums.

Test cases

case 1
in: [[1,2,3,4,5,6],[1,3]]
expected: [[1,2,3,4,5,6],[6,15]]
case 2
in: [[1,2,3],[2,5]]
expected: [[3],[]]
case 3
in: [[],[1]]
expected: [[]]
case 4
in: [[1,2,3,4],[2]]
expected: [[3,7]]
Starter codePython
def temporal_hierarchy_aggregation(series, scales):
    # Your code here
    pass

4 test cases · run your code against them in the editor