4 ms·
I'm not sure why I missed the combinations(..., 0), I'm pretty certain to have tested in a previous iteration (maybe because I wasn't using math.prod() initiall
by ux 4y ago
I'm not sure why I missed the combinations(..., 0), I'm pretty certain to have tested in a previous iteration (maybe because I wasn't using math.prod() initially); code and text adjusted.
For the map yeah I thought it wasn't recommended by Python style but I personally prefer it so I'm adopting that change as well.
For the sign change, your initial comment (before your edits) was proposing the (1, -1)[i & 1] trick, which I actually like better than negating all the roots. At least for clarity in understanding the blog post (which mentions the sign juggling), I think it's better to keep it that way. I added a link to your comment for anyone looking for further improvement.
Thanks for the all the suggestions :)