0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ペントミノをExact cover問題として解く(その4)

Posted at

前回の投稿でペントミノをExact cover問題と考えpythonのDLX packageを使って2339個の解答を得ることが出来ました。

今回はペントミノのボードの形を変えてもボードのデータを変更するだけで、同様に解けることを確認します。

サイズの違う長方形のボード

これらは単純にX,Yを変更するだけです

長方形(20x3)

X, Y = 20, 3

image.png

長方形(15x4)

X, Y = 15, 4

image.png

長方形(12x5)

X, Y = 12, 5

image.png

ボードの中央に4個の穴がある場合

これは8x8のボードを作って中央の4個のセルを除くだけでOKです。

X, Y = 8, 8
boardset = {(x,y) for y in range(Y) for x in range(X)} - {(4, 4), (3, 3), (3, 4), (4, 3)}

十字架

一見難しそうですが、縦長と横長の長方形と和集合を作りました。

X, Y = 9, 14
boardset = {(x,y) for y in range(8,10+1) for x in range(X)} | {(x,y) for y in range(Y) for x in range(3,5+1)}

(まとめ)ペントミノの各ボードの解答の総数とユニークな解答の数

Board Solution unique
長方形 20x3 8 2
長方形 15x4 1472 368
長方形 12x5 4040 1010
長方形 10x6 9356 2339
正方形 8x8-4 520 65
十字架 42 21

(開発環境:Google Colab)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?