Skip to content

Instantly share code, notes, and snippets.

@zahash
Created January 5, 2019 06:34
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 zahash/ce5b7e45ab42e3e34a997d2651194c6b to your computer and use it in GitHub Desktop.
Save zahash/ce5b7e45ab42e3e34a997d2651194c6b to your computer and use it in GitHub Desktop.
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