+ 3
Please help me in Python.
https://code.sololearn.com/c9r4xKb9576V/?ref=app This is a sudoku validator, the block rule isn't applied yet. There is a mistake in the first row of it, that 3 is repeated. I was just testing it to check if it is working fine in checking the rows and columns but what the output comes is so abnormal. Can you please check it and tell me where's the mistake.
7 odpowiedzi
+ 5
Change lines 20-39 for this.
for z in range(9):
#Row check
if point == sudoku[x][z]:
cir += 1
#Column check
if point == sudoku[z][y]:
cic += 1
if cic >= 2:
print(f'{point} in column {y+1} is repeated.')
ch = False
if cir >= 2:
print(f'{point} in row {x+1} is repeated.')
ch = False
cir = cic = 0
if ch != False:
return "This is a valid sudoku."
else:
return "This is not a valid sudoku"
+ 3
Samad Sama Remove one level of indentation in lines 27-33.
Change
if cir >= 2:
to
if cir >= 2:
and so on.
+ 3
Samad Sama
1. It's not working because the initial value of ch is 0, which equals False.
2. It won't print the mistakes because there aren't.
+ 2
Diego Oh yeah! It worked! It worked!
Thank you so much
+ 2
Once you decided on Numpy array you might use specific count and slicing methods.
+ 1
Diego Thank you
But now this code is just verifying the sudoku and not telling the mistakes in it.
+ 1
Diego still not working 🙁
Now I'm gonna restart making it.