Generate Sequence
fun tribonacci(signature: DoubleArray, n: Int) = generateSequence(Triple(signature[0], signature[1], signature[2])) {
Triple(it.second, it.third, it.first + it.second + it.third) }
.map { it.first }
.take(n)
.toList()
.toDoubleArray()
fun main() {
val array = doubleArrayOf(1.0,1.0,1.0)
tribonacci(array, 10)
}
// You can test using JUnit or KotlinTest. JUnit is shown below
// TODO: replace this example test with your own, this is just here to demonstrate usage.
// TODO: replace with whatever your package is called
package solution
import kotlin.test.assertEquals
import org.junit.Test
class TestExample {
@Test
fun tribonacci() {
}
}