Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oneline #37

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
"."
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
"python.testing.pytestEnabled": true,
"editor.tabSize": 4,
"editor.insertSpaces": true,
"editor.renderWhitespace": "all"
}
2 changes: 1 addition & 1 deletion simple_sudoku.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Example is take from:
# https://saturncloud.io/blog/python-sudoku-wave-function-collapse-algorithm-implementation/
#
# simply use: python simple_sudoky.py to run this program
# simply use: python simple_sudoku.py to run this program
#

iterations = 0
Expand Down
5 changes: 4 additions & 1 deletion src/sudoku/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ def get_matrix(content):
"""

if isinstance(content, str): # split textblob into list of lines
content = content.splitlines()
if len(content) == 81 and '\n' not in content: # assume a single line
content = [content[i:i+9] for i in range(0,81,9)]
else: # assume textblob with newlines
content = content.splitlines()

lines = []
for line in content:
Expand Down
1 change: 0 additions & 1 deletion tests/test_printer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from contextlib import redirect_stdout
import io

import sudoku as ss
from sudoku.printer import display_grid

sudoku_grid = [
Expand Down
10 changes: 9 additions & 1 deletion tests/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
790000000
"""

example1_str = '.......92...1...4.9..24...78..7..15.65.9.1.78.74..8..63...95..1.8...6...79.......'

example2 = """# this is a **** level puzzle from parool 2023-09-19
.6....19.
..261...4
Expand Down Expand Up @@ -76,12 +78,18 @@
assert m == example1_list


def test_example1_str():
assert len(example1_str) == 81
Dismissed Show dismissed Hide dismissed
m = reader.get_matrix(example1_str)
assert m == example1_list


def test_example2():
m = reader.get_matrix(example2)
assert m == example2_list


def test_reader():
def test_filereader():
# it is all relative from where pytest starts
m = reader.read_matrix("./data/example1.txt")
assert m == example1_list
Expand Down
Loading