We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
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.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #147: Rectangles in cross-hatched grids
You are viewing a single comment's thread. Return to all 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.