Created
January 5, 2019 06:34
-
-
Save zahash/ce5b7e45ab42e3e34a997d2651194c6b 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
def display(values): | |
""" | |
Display the values as a 2-D grid. | |
Input: The sudoku in dictionary form | |
Output: None | |
""" | |
print('') | |
rows = 'ABCDEFGHI' | |
cols = '123456789' | |
boxes = cartesian_product(rows, cols) | |
width = 1+max(len(values[s]) for s in boxes) | |
line = '+'.join(['-'*(width*3)]*3) | |
for r in rows: | |
print(''.join(values[r+c].center(width)+('|' if c in '36' else '') | |
for c in cols)) | |
if r in 'CF': print(line) | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment