Anonymous user
Pentomino tiling: Difference between revisions
→{{header|Python}}: pre-generate shifted minos
(→{{header|Python}}: pre-generate shifted minos) |
|||
Line 1,473:
=={{header|Python}}==
<lang python>from itertools import product
minos = (((197123, 7, 6), (1797, 6, 7), (1287, 6, 7), (196867, 7, 6)), ((263937, 6, 6), (197126, 6, 6), (393731, 6, 6), (67332, 6, 6)),
((16843011, 7, 5), (2063, 5, 7), (3841, 5, 7), (271, 5, 7), (3848, 5, 7), (50463234, 7, 5), (50397441, 7, 5), (33686019, 7, 5)),
Line 1,485 ⟶ 1,486:
((132866, 6, 6),))
tiles = []
def show(seq):▼
tiles.append([])
for n, x, y in row:
for shift in (b*8 + a for a, b in product(range(x), range(y))):▼
tiles[-1].append(n << shift)
b = [[-1]*10 for _ in range(10)]
Line 1,496 ⟶ 1,505:
hori = ([' _'[b[i+1][j] != b[i][j]] for j in range(1, 10)] for i in range(9))
def tile(board, i, seq=tuple()):
if not i:
else:
for c in [c for c in tiles[i - 1] if not board & c]:
▲ for c, x, y in minos[i - 1]:
▲ for shift in (b*8 + a for a, b in product(range(x), range(y))):
▲ tile(board|cc, i - 1, (cc,) + seq)
▲tile(0, len(minos))</lang>
{{out}}
<pre> _ _ _ _ _ _ _
Line 1,532 ⟶ 1,538:
.
.</pre>
=={{header|Raku}}==
{{trans|Java}}
|