PyRival icon indicating copy to clipboard operation
PyRival copied to clipboard

Template for modulo operations

Open bjorn-martinsson opened this issue 4 years ago • 4 comments

One of the most common codes that I've looked up over time is a mod template that I wrote many years ago for a private repository. It is useful enough to be used around once every second competition.

I cleaned up my old code, and added some extra features to it. I think this could be a super useful template to have on PyRival!

Note that I have yet to add tests to it, I will do that tomorrow.

@cheran-senthil What do you think about this template? I think it is both very simple and super useful to have.

bjorn-martinsson avatar Jun 16 '20 01:06 bjorn-martinsson

As a small note on the fast mod mul. Locally on my windows computer using PyPy the code runs around a factor of 10 faster with modmul compared to doing a * b % MOD.

bjorn-martinsson avatar Jun 16 '20 01:06 bjorn-martinsson

With the new version of PyPy on Windows, what are your thoughts on this moving forward?

cheran-senthil avatar May 06 '21 16:05 cheran-senthil

With the new version of PyPy on Windows, what are your thoughts on this moving forward?

Once CF updates (assuming it ever updates) then we can remove all the fast modmul stuff from the template. But I still think this template has its uses even after that.

bjorn-martinsson avatar May 06 '21 18:05 bjorn-martinsson