I'm having trouble making a function that places a number inside a binary grid. For instance, if i'm given 4 3 2 1, and I have a grid that is 5x5, it would look like the following...
4 4 4 4 1
4 4 4 4 0
4 4 4 4 0
4 4 4 4 0
0 0 0 0 0
My current code reads a text file and creates a list that is arranged in descending order. For instance if the text file contained 1 2 3, it would create a list of integers 3 2 1. Also my code prompts for a bin # which creates a binxbin square. I don't know how to actually place in a number 4 for the bin. This is the function that should place in the values which i'm stuck with.
def isSpaceFree(bin, row, column, block):
if row + block > len(bin):
return False
if column + block > len(bin):
return False
if bin[row][column] == 0 :
return True
else:
return False
for r in range(row, row+block):
if bin[row][column] != 0:
4?4 3 2 1,1 2 3or3 2 1have anything to do with how you fill the 5x5 grid? Is it always a 5x5 grid?