Back
Close

Conjecture

Statement

 Goal

Take a sequence s of n numbers and repeatedly push to the back its current sum, modulo the current length of the sequence. Conjecture: the sequence converges to some integer c.

Given a sequence s compute the limit c.

Example:
2
1 5
>> 6 % 2 = 0
>> 6 % 3 = 0
>> 6 % 4 = 2
>> 8 % 5 = 3
>> 11 % 6 = 5
>> 16 % 7 = 2
>> 18 % 8 = 2
>> etc. = 2

The final sequence is: final_s = [1, 5, 0, 0, 2, 3, 5, [2..]]
where [2..] is an infinite sequence of 2s. The output should then be 2.

Feel free to prove why this works (or if it doesn't). I have no idea.
Input
Line 1: An integer n for the number of points to compare.
Line 2: A sequence s of n space-separated integers.
Output
Line 1: An integer for the limit c of s.
Constraints
0 < n < 20
for all x in s, 0 < x < 100000
n < the length of the sequence prior to reach the limit c < 2000
Example
Input
2
1 5
Output
2

Game modes
Fastest, Shortest

Test cases
Test 1 Test
Input
2 1 5
Output
2

Validator 1 Validator
Input
2 1 1
Output
97

Test 2 Test
Input
1 9
Output
316

Validator 2 Validator
Input
1 99
Output
316

Test 3 Test
Input
3 1 4 15
Output
4

Validator 3 Validator
Input
5 7 10 12 25 39
Output
14

Test 4 Test
Input
2 999 99
Output
36

Validator 4 Validator
Input
2 999 999
Output
62

Test 5 Test
Input
9 78 12 3 82 23 99999 1 1 1
Output
326

Validator 5 Validator
Input
9 999 12 3 82 23 99999 1 1 1
Output
335

Test 6 Test
Input
3 6 6 6
Output
3

Validator 6 Validator
Input
1 666
Output
58

Test 7 Test
Input
4 1 3 3 7
Output
3

Validator 7 Validator
Input
1 1337
Output
35

Test 8 Test
Input
5 1 678 3 3 8
Output
27

Validator 8 Validator
Input
5 9 1 9 1 9
Output
11

Test 9 Test
Input
4 1 4 15 30
Output
316

Validator 9 Validator
Input
6 4 31 23 38 14 7
Output
10

Solution language

Solution

Stub generator input