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