Tribonacci Builder
Tribonacci works like Fibonacci, but each new value is built from the previous three numbers instead of two. Write tribonacci, which takes a starting triple signature and a result length n. Return the first n values of the sequence. If n is 0, return an empty list.
Примеры
Ввод
[1, 1, 1], 10Вывод
[1, 1, 1, 3, 5, 9, 17, 31, 57, 105]Ввод
[0, 0, 1], 10Вывод
[0, 0, 1, 1, 2, 4, 7, 13, 24, 44]Ввод
[1, 0, 0], 10Вывод
[1, 0, 0, 1, 1, 2, 4, 7, 13, 24]Нужно реализовать
def tribonacci(signature: list[int], n: int) -> list[int]:
Теги
listsmath
Logga in för att se historik över inskick
Logga inLogga in för att använda AI-mentorn
Logga inVisible tests
1
Input
[1,1,1], 10Expected
[1,1,1,3,5,9,17,31,57,105]2
Input
[0,0,1], 10Expected
[0,0,1,1,2,4,7,13,24,44]3
Input
[1,0,0], 10Expected
[1,0,0,1,1,2,4,7,13,24]4
Input
[0,1,1], 0Expected
[]5
Input
[1,2,3], 1Expected
[1]6
Input
[1,2,3], 2Expected
[1,2]Focus radio
Paused · SomaFM · Fluid