This file contains hidden or 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
# See https://puzzling.stackexchange.com/q/132979/99846 | |
# Converts from (x, y) coordinates to an index in `range(81)`. | |
def xy_to_index(x, y): | |
return x + 9 * y | |
# Converts from an index in `range(81)` to (x, y) coordinates. | |
def index_to_xy(i): | |
return i % 9, i // 9 |