Project Euler #147: Rectangles in cross-hatched grids

  • + 0 comments

    The formula of number of all upright rectangles is relatively easy to get. Much more challenging is to derive formula for diagonal ones. To do so you have to solve the system of linear equations. I did it using my own implementation of Gauusian elimination. You need also to implement function that counts diagonal for some small values. Last one thing is to use proper modulo inverse of 36 and 60 as these are the values that appear in formulas for upright and diagonal rectangles.