All problems
Growth Function of Intervals
Problem
Return the growth function of intervals on the real line for n points in general position:
m(n) = 1 + n + n * (n - 1) / 2
An interval realizes every contiguous block of points plus the empty set.
Hint
The growth function counts distinct labelings realizable on n points.
Test cases
case 1
in: [0]
expected: 1
case 2
in: [1]
expected: 2
case 3
in: [2]
expected: 4
case 4
in: [3]
expected: 7
case 5
in: [5]
expected: 16
Starter codePython
def growth_function_intervals(n):
# Your code here
pass5 test cases · run your code against them in the editor