Skip to content

Instantly share code, notes, and snippets.

@Yepoleb
Last active November 19, 2019 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yepoleb/693198593f75bb36aa83d46c75c8e26e to your computer and use it in GitHub Desktop.
Save Yepoleb/693198593f75bb36aa83d46c75c8e26e to your computer and use it in GitHub Desktop.
summands = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]
def rowsum(row):
s = 0
for x in row:
s += summands[x]
return s
valid_sum = rowsum([1, 2, 3, 4, 5, 6, 7, 8, 9])
def is_sudokurow(row):
return rowsum(row) == valid_sum
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