Impressed, the Elves issue you a challenge: determine the 30000000
th number spoken. For example, given the same starting numbers as above:
0,3,6
, the 30000000
th number spoken is 175594
.1,3,2
, the 30000000
th number spoken is 2578
.2,1,3
, the 30000000
th number spoken is 3544142
.1,2,3
, the 30000000
th number spoken is 261214
.2,3,1
, the 30000000
th number spoken is 6895259
.3,2,1
, the 30000000
th number spoken is 18
.3,1,2
, the 30000000
th number spoken is 362
.Given your starting numbers, what will be the 30000000
th number spoken? Determine this in the following way:
recitation
that takes two arguments: i) a list of starting numbers (str
) and ii) a turn \(n \in \mathbb{N}_0\). The function must return the \(n\)-th number (int
) spoken.>>> recitation('0,3,6', 2020)
436
>>> recitation('1,3,2', 2020)
1
>>> recitation('2,1,3', 2020)
10
>>> recitation('1,2,3', 2020)
27
>>> recitation('2,3,1', 2020)
78
>>> recitation('3,2,1', 2020)
438
>>> recitation('3,1,2', 2020)
1836
>>> recitation('0,3,6', 30000000)
175594
>>> recitation('1,3,2', 30000000)
2578
>>> recitation('2,1,3', 30000000)
3544142
>>> recitation('1,2,3', 30000000)
261214
>>> recitation('2,3,1', 30000000)
6895259
>>> recitation('3,2,1', 30000000)
18
>>> recitation('3,1,2', 30000000)
362