Python 3.5, 194 181 169 152 149 146 bytes:
(Thanks to @Sherlock9 for 2 bytes!)
def r(o,c=0):
y=[[j%i for i in range(2,100)]for j in range(o+1)]
while 1:
c+=1;z=y[-1][:c]
if z not in[f[:c]for f in y[:-1]]:break
print(z)
Works perfectly, and is also pretty quick. Calculating for the minimal remainder sequence of 100000
outputs [0, 1, 0, 0, 4, 5, 0, 1, 0, 10, 4, 4]
and took only about 3 seconds. It was even able to calculate the sequence for the input 1000000
(1 million), output [0, 1, 0, 0, 4, 1, 0, 1, 0, 1, 4, 1, 8, 10, 0, 9]
, and took about 60 seconds.
Explanation
Basically what this function does is firstly create a list, y
, with all j mod i
where j
is every integer in the range 0=>7
(including 7) and i
is every integer in the range 0=>100
. The program then goes into an infinite while
loop and compares the same number of contents of each sublist within the first through second-to-last sublists of y
(y[:-1:]
) with the same number of items in the last sublist (y[-1]
) of list y
. When sublist y[-1]
is different than any other sublist, the loop is broken out of, and the correct minimal remainder sequence is returned.
For instance, if the input is 3, y
would be:
[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]]
Then, when it enters into the while loop, it compares each sublist in list y[:-1:]
with the same number of items in sublist y[-1]
. For example, it would first compare [[0],[1],[0]]
and [1]
. Since the last sublist is in the rest of y
, it would continue on and then compare [[0,0],[0,1],[0,2]]
and [1,0]
. Since [1,0]
is now NOT in the rest of y
in that specific order, that is the minimal reminder sequence, and therefore, [1,0]
would be correctly returned.