Skip to content

Commit

Permalink
Merge pull request #38 from havardox/upstream
Browse files Browse the repository at this point in the history
Fix markdown formatting
  • Loading branch information
jwg4 authored Nov 3, 2022
2 parents d199777 + d3739c2 commit a357632
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 40 deletions.
18 changes: 9 additions & 9 deletions examples/constants.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
```
```python
>>> from polyomino.constant import *
>>> from polyomino.piece import display

```

```
```python
>>> print(display(TETROMINOS['T']))
+-+-+-+
| |
Expand All @@ -14,7 +14,7 @@

```

```
```python
>>> print(display(TETROMINOS['J']))
+-+-+
| |
Expand All @@ -26,7 +26,7 @@

```

```
```python
>>> print(display(TETROMINOS['Square']))
+-+-+
| |
Expand All @@ -36,15 +36,15 @@

```

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

```

```
```python
>>> print(display(TETROMINOS['S']))
+-+-+
| |
Expand All @@ -54,7 +54,7 @@

```

```
```python
>>> print(display(ONESIDED_TETROMINOS['L']))
+-+-+
| |
Expand All @@ -66,12 +66,12 @@

```

```
```python
>>> print(display(ONESIDED_TETROMINOS['Z']))
+-+-+
| |
+-+ +-+
| |
+-+-+

```
```
2 changes: 1 addition & 1 deletion examples/easy.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This shows a simple example of how to use the module.

```
```python
>>> from polyomino.constant import TETROMINOS
>>> from polyomino.board import Rectangle
>>> tile = TETROMINOS['T']
Expand Down
12 changes: 6 additions & 6 deletions examples/fluid.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
## Examples of fluid syntax to construct problems

```
```python
>>> from polyomino.board import Chessboard
>>> from polyomino.constant import MONOMINO, DOMINO
>>> from polyomino.tileset import many

```

```
```python
>>> Chessboard()
<polyomino.board.Chessboard object at ...>

```

```
```python
>>> Chessboard().tile_with_many(DOMINO)
<polyomino.problem.TilingProblem object at ...>

```

```
```python
>>> Chessboard().tile_with_set(many(DOMINO).and_repeated_exactly(2, MONOMINO))
<polyomino.problem.TilingProblem object at ...>

```

```
```python
>>> Chessboard().tile_with_set(many(DOMINO).and_repeated_exactly(2, MONOMINO)).with_heuristics()
<polyomino.problem.TilingProblem object at ...>

```
```
39 changes: 19 additions & 20 deletions examples/gardner.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
These examples are taken from chapter 13 of 'Mathematical Puzzles and Diversions' by Martin Gardner.

```
```python
>>> from polyomino.board import Chessboard, Rectangle
>>> from polyomino.constant import MONOMINO, DOMINO
>>> from polyomino.constant import RIGHT_TROMINO, STRAIGHT_TROMINO
Expand All @@ -9,31 +9,31 @@ These examples are taken from chapter 13 of 'Mathematical Puzzles and Diversions
>>> from polyomino.tileset import many, repeated_exactly, any_number_of

```


> ...
> In Chapter 3 (problem 3) we considered a polyomino problem dealing with the placing of dominoes on a mutilated chessboard.
>[...]
>In Chapter 3 (problem 3) we considered a polyomino problem dealing with the placing of dominoes on a mutilated chessboard.
(We can't solve this problem within a doctest because it takes too long.)
```

```python
>>> Chessboard().remove((0, 0)).remove((7, 7)).tile_with_many(DOMINO)
<polyomino.problem.TilingProblem object at ...>

```

[An impossible tiling will give the solution None.]
```
[An impossible tiling will give the solution `None`.]

```python
>>> Rectangle(4, 4).remove((0, 0)).remove((3, 3)).tile_with_many(DOMINO).solve()

```

```
```python
>>> Chessboard().remove((0, 0)).remove((0, 7)).tile_with_many(DOMINO).solve().tiling
[[(0, 1), (0, 2)], [(0, 3), (0, 4)], [(0, 5), (0, 6)], [(1, 0), (1, 1)], [(1, 2), (1, 3)], [(1, 4), (1, 5)], [(1, 6), (1, 7)], [(2, 0), (2, 1)], [(2, 2), (2, 3)], [(2, 4), (2, 5)], [(2, 6), (2, 7)], [(3, 0), (3, 1)], [(3, 2), (3, 3)], [(3, 4), (3, 5)], [(3, 6), (3, 7)], [(4, 0), (4, 1)], [(4, 2), (4, 3)], [(4, 4), (4, 5)], [(4, 6), (4, 7)], [(5, 0), (5, 1)], [(5, 2), (5, 3)], [(5, 4), (5, 5)], [(5, 6), (5, 7)], [(6, 0), (6, 1)], [(7, 0), (7, 1)], [(6, 2), (6, 3)], [(7, 2), (7, 3)], [(6, 4), (6, 5)], [(7, 4), (7, 5)], [(6, 6), (6, 7)], [(7, 6), (7, 7)]]

```

```
```python
>>> print(Chessboard().remove((0, 0)).remove((0, 7)).tile_with_many(DOMINO).solve().display())
+-+-+-+-+-+-+-+
| | | | | | | |
Expand All @@ -55,7 +55,7 @@ These examples are taken from chapter 13 of 'Mathematical Puzzles and Diversions

```

```
```python
>>> print(Chessboard().remove((2, 2)).tile_with_many(STRAIGHT_TROMINO).solve().display())
+-+-+-+-+-+-+-+-+
| | | | | | |
Expand All @@ -77,7 +77,7 @@ These examples are taken from chapter 13 of 'Mathematical Puzzles and Diversions

```

```
```python
>>> print(Chessboard().tile_with_set(many(STRAIGHT_TROMINO).and_one(MONOMINO)).solve().display())
+-+-+-+-+-+-+-+-+
| | | | | | | | |
Expand All @@ -99,12 +99,12 @@ These examples are taken from chapter 13 of 'Mathematical Puzzles and Diversions

```

```
```python
>>> Chessboard().remove((2, 3)).tile_with_many(STRAIGHT_TROMINO).solve()

```

```
```python
>>> print(Chessboard().remove((4, 5)).tile_with_many(RIGHT_TROMINO).solve().display())
+-+-+-+-+-+-+-+-+
| | | | | |
Expand All @@ -126,20 +126,21 @@ These examples are taken from chapter 13 of 'Mathematical Puzzles and Diversions

```

```
```python
>>> [name for name in ONESIDED_TETROMINOS if Chessboard().tile_with_many(ONESIDED_TETROMINOS[name]).solve() is None]
['S', 'Z']

```

As mentioned on p118, there is an easy argument to show that this is impossible - naive search is computationally intractable.
```

```python
>>> Chessboard().tile_with_set(any_number_of([ONESIDED_TETROMINOS['L'], ONESIDED_TETROMINOS['J']]).and_one(TETROMINOS['Square']))
<polyomino.problem.TilingProblem object at ...>

```

```
```python
>>> print(Chessboard().tile_with(ALL_PENTOMINOS + [TETROMINOS['Square']]).solve().display())
+-+-+-+-+-+-+-+-+
| | | |
Expand All @@ -159,6 +160,4 @@ As mentioned on p118, there is an easy argument to show that this is impossible
| | | | |
+-+-+-+-+-+-+-+-+

```

```
8 changes: 4 additions & 4 deletions examples/more.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
```
```python
>>> from polyomino.board import Irregular, Rectangle
>>> from polyomino.constant import TETROMINOS

```

```
```python
>>> board = Irregular([(i, j) for i in range(0, 12) for j in range(0, 16)])
>>> problem = board.tile_with_many(TETROMINOS['T'])
>>> solution = problem.solve()
Expand Down Expand Up @@ -45,7 +45,7 @@

```

```
```python
>>> LEFT_CAP_13_HEIGHTS = [
... 0, 1, 0, 1, -1, -1, -1, -1, -1, -2, -1, -2, -1
... ]
Expand Down Expand Up @@ -105,4 +105,4 @@
| | | |
+-+ +-+

```
```

0 comments on commit a357632

Please sign in to comment.