So, in my program I have a "main" function, which changes two elements of a given matrix. The matrix is an element of a list (in the example the list is the variable solved) and then I want to append three new elements.
def main(matrix,direction):
index16 = indexOf(16,matrix)
matrix[index16[0]][index16[1]],matrix[index16[0]-1][index16[1]]=matrix[index16[0]-1][index16[1]],matrix[index16[0]][index16[1]]
return matrix
solved = [[[2,1,3,4],
[5,6,7,8],
[9,10,11,12],
[13,14,15,16]
]]
not_solved = [[0,"up"],
[0,"left"]
]
while not_solved:
solved.append(main(solved[not_solved[0][0]],not_solved[0][1]))
break
When I execute the program, I can see the "solved" array. However the initial matrix stays the same as in the beginning.
[[[2, 1, 3, 4], [5, 6, 7, 8], [9, 10, 11, 16], [13, 14, 15, 12]],
[[2, 1, 3, 4], [5, 6, 7, 8], [9, 10, 11, 16], [13, 14, 15, 12]]]
How can I repair that?
Sorry for my English. I am still learning.
indexOfsomewhere?