Skip to content
DeepForgeby svx
All problems
EasyTime Seriests-295

MSTL Period Count

Problem

Count how many distinct seasonal periods in the candidate list are usable for MSTL. A period qualifies when it is at least 2 and at least two full cycles fit in n observations, that is n // period >= 2.

Duplicate candidates count once.

Hint

A period needs room for at least two cycles before it can be separated.

Test cases

case 1
in: [[7,30,365],400]
expected: 2
case 2
in: [[4,4,8],100]
expected: 2
case 3
in: [[1,2],3]
expected: 0
case 4
in: [[],100]
expected: 0
case 5
in: [[24,24],48]
expected: 1
Starter codePython
def mstl_period_count(periods, n):
    # Your code here
    pass

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