Does anyone have a proof of the period of an iterated polynomial in a field? I know
x+b (b>0) has period
p and
a*x (a>0,x>1 or a>1,x>0) has period
p-1, but for
a*x+b I could only assume that it has period
p or, in the end,
p-1 because I was off by one. ...Which makes sense because when
a>1 there's exactly one identity
e=ae+b --> b=e(1-a) --> e=b/(1-a)=b*c for any
b because every non-zero element (
1-a) has a unique inverse.
>>1154
Same. It would've actually been better if he did ask for position 2019, because now part 1 is just a trivial case of part 2.
Today is definitely big brain time, unless you cheat yourself and look up the algorithms. I know my finite fields and still it took 4 hours to get the right answer. That includes lots of off-by-one errors and I-have-no-fucking-clue-because-it's-all-opaque-numbers errors.
I highly recommend you keep printing the output of part 1 using your part 1 algorithm AND using your part 2 algorithm the whole time.
>>1155
Protip 1: you get back to the original deck after 119315717514046 shuffles, so why shuffle backwards a lot when you can shuffle forwards slighty less?
Protip 2: write the shuffle operations as functions from the old position to the new position, e.g. restacking is
new = -old-1 (mod length).
2.1: When your shuffle operations all look like new=a*old+b you can compose them and turn all the operations in your input into a single one, e.g. r=p+7, s=3*r+0 --> s=3*(p+7)+0=3*p+21.2.2: Put differently, cut -7 turns any [a,b] into [a,b+7] and restacking turns [a,b] into [-a,-1-b], with [a,b] starting at [1,0] because no operation must mean p=1*p+0 of course.
Protip 3:
Find a shortcut for applying a linear function a trillion times. :^)