Skip to content
DeepForgeby svx
All problems
EasyNLPnlp-213

Energy Contour

Problem

Return the frame energy contour: the sum of squared samples for each frame.

Negative samples square to positive energy, and an empty frame list gives an empty contour.

Hint

Squaring removes sign and gives frame energy.

Test cases

case 1
in: [[[1,2],[3,4]]]
expected: [5,25]
case 2
in: [[[0]]]
expected: [0]
case 3
in: [[]]
expected: []
case 4
in: [[[-1,-2]]]
expected: [5]
Starter codePython
def energy_contour(frames):
    # Your code here
    pass

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