I am working on a Sudoku Solver in Python, and I need to create functions in it. One of them checks the Sudoku Matrix and returns the number of rows in it that contains a repeating number.
def findRepeatsInColumn(matrix):
numRepeats = 0
for row in matrix:
safeChars=['[', ']', '/']
usedChars=[]
for char in str(row):
if char in usedChars and char not in safeChars:
numRepeats += 1
break
else:
usedChars.append(char)
return numRepeats
If I pass a matrix [[1, 1, 1], [2, 2, 2], [3, 3, 3]] to it, it functions fine and gives me the output 3, but for checking all columns for repeated numbers, I need to convert the rows into columns, which means I would need something like: Input: [[1, 1, 1], [2, 2, 2], [3, 3, 3]]
Output: [[1, 2, 3], [1, 2, 3], [1, 2, 3]]
Any thoughts on how I could do this without NumPy?
[[1, 1, 1], [2, 2, 2], [3, 3, 3]]instead of[[111], [222], [333]]