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.
Project Euler #147: Rectangles in cross-hatched grids
Project Euler #147: Rectangles in cross-hatched grids
Sort by
recency
|
7 Discussions
|
Please Login in order to post a comment
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.
yes, but in a 3x2 grid there are 1 possible 3x2 grid -> 37(18 upright + 19 diagonal) 6 possible 1x1 grids -> 6(6 upright + 0 diagonal) 4 possible 2x1 grids -> 16(12 upright + 4 diagonal) 2 possible 3x1 grids -> 16(12 upright + 4 diagonal) 3 possible 1x2 grids -> 12(9 upright + 3 diagonal) 2 possible 2x2 grids ->36 (18 upright + 18 diagonal) so, total = 37 +6 + 16 + 16 + 12 + 36 = 123 out of 123, 75 =(18+9+12+12+6+18) are upright and 48= (19+4+4+3+18) are diagonal
It is given that the number of 1*1 grid is 1.....How is that possible ...there are so many 1*1 grid ..plz explain the terminology of 3*2,1*1 etc...
Please I really need clarifications with the wording of this question.
Let grid size is MxN (M<=N)
for upright rectangles of m <= M & n <= N
number of rectangles possible is (1+(M-m))*(1+(N-n)) usin this I can get upright rectangles of all sizes.
for diagonal rectangles I could only figure out for 1xn (and nx1) sizes.
how to figure out rest of the diagonal rectangles?
Any help!