Just when I think I'm decent at something, I find a simple thing I cannot overcome.
I need to create a symmetrical row x column matrix given a start and block for a checksum. The entries should be in sequential order.
def main(start_index, block):
num_rows, num_cols = block, block
matrix = []
for r in range(num_rows):
temp = []
for c in range(num_cols):
temp.append(c)
matrix.append(temp)
return matrix
The output here is:
[[0, 1, 2], [0, 1, 2], [0, 1, 2]]
What I'm trying to obtain is:
[[0, 1, 2], [3, 4, 5], [6, 7, 8]]
And not just for a 3x3 but dynamically as well.
Note: No packages like numpy, that's not the point of this ask. Only native python.