Skip to content

Instantly share code, notes, and snippets.

@bholzer
Created June 23, 2014 22:53
Show Gist options
  • Save bholzer/d728fb960e279c3743ea to your computer and use it in GitHub Desktop.
Save bholzer/d728fb960e279c3743ea to your computer and use it in GitHub Desktop.
def checkRows(g):
for rows in g:
numbersInRow = [] #List to keep track of numbers that appear in the row
for number in row:
if number != 0 and number in numbersInRow:
return g.index(row) #The number has already appeared in the row, so return the row that fails
else:
numbersInRow.append(number) #This number hasnt appeared in the row yet, so add it to the list
print(numbersInRow)
return True #Nothing failed, so the row check succeeded
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment