ROSECODE 190
The Best Sub-sequence
Consider the decimal part of PI by groups of 2 digits.
We get the following sequence for the 20 first elements:
Now group the decimal part of PI by groups of 10 digits and subtract 10^10/2 from each element.
We get the sequence:
Answer format: Sum,Starting index,Ending index
Example: 110,3,7
[My timing: 2 sec] // Computation of PI not included!
We get the following sequence for the 20 first elements:
14,15,92,65,35,89,79,32,38,46,26,43,38,32,79,50,28,84,19,71Subtract from each element of this sequence 50:
-36,-35,42,15,-15,39,29,-18,-12,-4,-24,-7,-12,-18,29,0,-22,34,-31,21You can verify that the sub-sequence starting at index 3 and ending at index 7 (42,15,-15,39,29) has the largest sum: 110.
Now group the decimal part of PI by groups of 10 digits and subtract 10^10/2 from each element.
We get the sequence:
S = -3584073465,3979323846,-2356616721,28841971,1939937510,820974944,923078164,-4371379101,3628034825,-1578829321, ...What is the sub-sequence with the largest sum in the first 5,000,000 elements of S?
Answer format: Sum,Starting index,Ending index
Example: 110,3,7
[My timing: 2 sec] // Computation of PI not included!