Project Euler #147: Rectangles in cross-hatched grids

Sort by

recency

|

7 Discussions

|

  • + 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.

  • + 0 comments

    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

  • + 0 comments

    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...

  • + 1 comment

    Please I really need clarifications with the wording of this question.

    when you say a 3x2 grid, I am thinking a grid with 3 rows and 2 columns and I cant see that here.

    Also it says "There are 5 grids smaller than 3x2, vertical and horizontal dimensions being important....",5 grids smaller? Please how do you define a grid ?

    Also where the problem said "Adding those to the 37 of the 3x2 grid, a total of 72 different rectangles" ... how did 72 come about. I can just think of 37 + 18 = 55.

  • + 1 comment

    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!