Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
nonogram_read_file
def initialize_from_file(self, filename):
with open(filename) as f:
# Board size
row_count = int(f.readline())
col_count = int(f.readline())
self.initialize(row_count, col_count)
# Read row hints, one row per line
self.row_hints = []
for i in range(0, self.no_rows):
line = f.readline()
numbers = [int(i) for i in line.split()]
self.row_hints.append(numbers)
# Read column hints, one column per line
self.col_hints = []
for i in range(0, self.no_cols):
line = f.readline()
numbers = [int(i) for i in line.split()]
self.col_hints.append(numbers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment