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 (String
) and ii) a turn \(n \in \mathbb{N}_0\). The function must return the \(n\)-th number (int
) spoken.This static function must be located in the class Submission
.
> Submission.recitation("0,3,6", 2020)
436
> Submission.recitation("1,3,2", 2020)
1
> Submission.recitation("2,1,3", 2020)
10
> Submission.recitation("1,2,3", 2020)
27
> Submission.recitation("2,3,1", 2020)
78
> Submission.recitation("3,2,1", 2020)
438
> Submission.recitation("3,1,2", 2020)
1836
> Submission.recitation("0,3,6", 30000000)
175594
> Submission.recitation("1,3,2", 30000000)
2578
> Submission.recitation("2,1,3", 30000000)
3544142
> Submission.recitation("1,2,3", 30000000)
261214
> Submission.recitation("2,3,1", 30000000)
6895259
> Submission.recitation("3,2,1", 30000000)
18
> Submission.recitation("3,1,2", 30000000)
362