I've got a MxN rectangular grid of cells, each containing a value. All thanks to Mathmate we know that, when M < N, there are \[\sum_{i=1}^{M}(M-i+1)(N-i+1)\]possible squares in such a grid. The question is, what are the values of each possible square in the grid? For a unicellular grid (an individual square), its value is the number between the brackets i.e. the value of [01] is 1, and for a multicellular square (a square grid of these cells) such as \[# [01][01] [01][01]\] The value of the above square is the sum of it's individual elements.
[00][01][02][03][04][05] [06][07][08][09][10][11] [12][13][14][15][16][17] [18][19][20][21][22][23] [24][25][26][27][28][29] [30][31][32][33][34][35] [36][37][38][39][40][41] [42][43][44][45][46][47] [48][49][50][51][52][53] Values of possible squares in the above grid are: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 62, 66, 70, 74, 78, 86, 90, 94, 98, 102, 110, 114, 118, 122, 126, 134, 138, 142, 146, 150, 158, 162, 166, 170, 174, 182, 186, 190, 194, 198, 63, 72, 81, 117, 135, 144, 171, 180, 189, 225, 234, 243, 252, 279, 288, 297, 306, 333, 342, 351, 360, 387, 396, 405, 414, 168, 184, 200, 264, 280, 296, 376, 392, 456, 472, 488, 552, 568, 584, 648, 664, 680, 350, 375, 500, 525, 650, 675, 800, 825, 950, 975, 630, 846, 1062, 1278]
Can you not march through the MxN grid with a 4-nested loop to sum the values and store in an array. Subsequently you'd sort the array and eliminate duplicate values to get the above list. I assume the values stored in the array are not related to the position of the elemental square.
Join our real-time social learning platform and learn together with your friends!