Skip to content

Instantly share code, notes, and snippets.

@lmeulen
Created January 14, 2022 20: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 lmeulen/19f5c596d2e4df95fe8b4a482db85efb to your computer and use it in GitHub Desktop.
Save lmeulen/19f5c596d2e4df95fe8b4a482db85efb to your computer and use it in GitHub Desktop.
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