Skip to content

Commit

Permalink
Merge pull request #24 from jwg4/fix_irregular_format_tiling
Browse files Browse the repository at this point in the history
Fix irregular format tiling
  • Loading branch information
jwg4 authored Mar 6, 2022
2 parents a966a28 + 25cdad2 commit abc991f
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 35 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/poetry-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
run: pip install poetry
- name: Install requirements
run: poetry install
- name: Test package
- name: run unit tests
run: poetry run test
- name: Test package
- name: run doctests
run: poetry run doctest
20 changes: 10 additions & 10 deletions examples/constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
| |
+-+ +-+
| |
+ +-+ +
+-+
```

Expand All @@ -20,17 +20,17 @@
| |
+-+ +
| |
+ + +
+ +
| |
+ +-+
+-+
```

```
>>> print(display(TETROMINOS['Square']))
+-+-+
| |
+ + +
+ +
| |
+-+-+
Expand All @@ -46,11 +46,11 @@

```
>>> print(display(TETROMINOS['S']))
+-+-+ +
+-+-+
| |
+-+ +-+
| |
+ +-+-+
+-+-+
```

Expand All @@ -60,18 +60,18 @@
| |
+ +-+
| |
+ + +
+ +
| |
+-+ +
+-+
```

```
>>> print(display(ONESIDED_TETROMINOS['Z']))
+ +-+-+
+-+-+
| |
+-+ +-+
| |
+-+-+ +
+-+-+
```
40 changes: 20 additions & 20 deletions examples/more.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,44 +65,44 @@
>>> board = Irregular(make_13_cylinder())
>>> print(board.display())
+ + + + + + + + + +-+ +-+ +
+-+ +-+
| | | |
+ + + + +-+-+-+-+-+ +-+ +-+
+-+-+-+-+-+ +-+ +-+
| |
+-+ +-+ + + + + + + + + + +
+-+ +-+ + +
| | | | | |
+ +-+ +-+ + + + + + + + + +
+ +-+ +-+ +
| |
+ + + + + + + + + + + + + +
+ +
| |
+ + + + + + + + + + + + + +
+ +
| |
+ + + + + + + + + + + + + +
+ +
| |
+ + + + + + + + + + + + + +
+ +
| |
+ + + + + + + + + + + + + +
+ +
| |
+ + + + + + + + + + + + + +
+ +
| |
+ + + + + + + + + + + + + +
+ +
| |
+ + + + + + + + + + + + + +
+ +
| |
+ + + + + + + + + + + + + +
+ +
| |
+ + + + + + + + + + + + + +
+ +
| |
+ + + + + + + + + + + + + +
+ +
| |
+ + + + + + + + + + + + + +
+ +
| |
+ + + + + + + + + +-+ +-+ +
+ +-+ +-+ +
| | | | | |
+ + + + +-+-+-+-+-+ +-+ +-+
+ +-+-+-+-+-+ +-+ +-+
| |
+-+ +-+ + + + + + + + + + +
+-+ +-+ +
| | | |
+ +-+ +-+ + + + + + + + + +
+-+ +-+
```
10 changes: 10 additions & 0 deletions polyomino/board.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import numpy as np

from pretty_poly import make_ascii

from .problem import TilingProblem
from .tileset import exactly, many
from .transform import rotations
Expand Down Expand Up @@ -67,6 +69,14 @@ def tile_with_set(self, tileset):
tileset.check(self)
return TilingProblem(self, tileset)

def display(self):
return make_ascii([self.squares])

def format_tiling(self, pieces):
squares_in_pieces = (sq for piece in pieces for sq in piece)
remainder = set(self.squares) - set(squares_in_pieces)
return make_ascii(pieces + [remainder])


class Irregular(Shape):
_adjusted = None
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "polyomino"
version = "0.6.2"
version = "0.6.3"
description = "Solve polyomino tiling problems."
readme = "README.md"
authors = ["Jack Grahl <[email protected]>"]
Expand All @@ -16,6 +16,7 @@ pretty-poly = "0.2.0"
pytest = "^6.2.1"
hypothesis = "^6.0.2"
pytest-profiling = "^1.7.0"
black = "^21.6b0"

[tool.poetry.scripts]
test = 'run_tests:run_tests'
Expand Down
4 changes: 2 additions & 2 deletions run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ def run_doctests():
for file in os.listdir("examples/"):
if not file.endswith(".md"):
continue
filepath = os.path.join("examples/", file)
doctest.testfile(filepath, optionflags=doctest.ELLIPSIS)
filepath = os.path.join("examples/", file)
doctest.testfile(filepath, optionflags=doctest.ELLIPSIS, raise_on_error=True)

0 comments on commit abc991f

Please sign in to comment.