Last active
November 19, 2019 17:24
-
-
Save Yepoleb/49231ee8b1024a4b35bb7c15100705e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PRIMES = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61] | |
def rowproduct(row): | |
p = 1 | |
for x in row: | |
p *= PRIMES[x] | |
return p | |
valid_product = rowproduct([1, 2, 3, 4, 5, 6, 7, 8, 9]) | |
def is_sudokurow(row): | |
return rowproduct(row) == valid_product | |
print(is_sudokurow([1, 2, 3, 4, 5, 6, 7, 8, 9])) | |
print(is_sudokurow([8, 2, 5, 4, 3, 6, 7, 1, 9])) | |
print(is_sudokurow([1, 2, 3, 4, 5, 6, 7, 7, 7])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment