Skip to content

Commit

Permalink
Save the notebook showing how to display solutions.
Browse files Browse the repository at this point in the history
  • Loading branch information
jwg4 committed Nov 11, 2023
1 parent 2f67293 commit bd4cc4f
Show file tree
Hide file tree
Showing 2 changed files with 178 additions and 22 deletions.
100 changes: 89 additions & 11 deletions examples/.ipynb_checkpoints/display_solutions-checkpoint.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,106 @@
"execution_count": 1,
"id": "c5f94563",
"metadata": {},
"outputs": [],
"source": [
"from polyomino.board import Chessboard, Irregular\n",
"from polyomino.constant import TETROMINOS, ALL_PENTOMINOS"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "a990b439",
"metadata": {},
"outputs": [],
"source": [
"solution = Chessboard().tile_with(ALL_PENTOMINOS + [TETROMINOS['Square']]).solve()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "24061091",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAMAAAC5zwKfAAAAKlBMVEUAAADHAmpXhq27nv0P09O+aOhDO+yTXJ/3b0Je9l31av2rSvJGyVnRuL77hKSIAAAAYklEQVR4nO3Mtw3AMBAEQULekOq/XGXP5HCQ0udOAVOmMP+2CIWQMHmorBYh4TjhFnyzh8MiJMweertFSJg9PIXrI0LCccI7qLqG3rTwCISE2UNV97BZhIQjhtVSDSFh8vAFbS7Jkaszv9kAAAAASUVORK5CYII=\n",
"text/plain": [
"<polyomino.solution.Solution at 0x6f537fe8>"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"solution"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "076e18a7",
"metadata": {},
"outputs": [
{
"ename": "ModuleNotFoundError",
"evalue": "No module named 'polyomino'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m/tmp/ipykernel_11300/1925078410.py\u001b[0m in \u001b[0;36m<cell line: 1>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mpolyomino\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mboard\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mChessboard\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mpolyomino\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mconstant\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mTETROMINOS\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mALL_PENTOMINOS\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'polyomino'"
"name": "stdout",
"output_type": "stream",
"text": [
"+-+-+-+-+-+-+-+-+\n",
"| | | |\n",
"+ +-+-+-+-+-+ +\n",
"| | | |\n",
"+-+ +-+ +-+-+-+-+\n",
"| | | | | |\n",
"+ +-+-+-+ +-+-+ +\n",
"| | | |\n",
"+-+-+-+-+-+-+ + +\n",
"| | | | |\n",
"+-+ +-+-+ +-+-+-+\n",
"| | | | | | |\n",
"+ +-+ + +-+ +-+ +\n",
"| | | | | |\n",
"+ +-+ +-+ +-+ +\n",
"| | | | |\n",
"+-+-+-+-+-+-+-+-+\n"
]
}
],
"source": [
"from polyomino.board import Chessboard\n",
"from polyomino.constant import TETROMINOS, ALL_PENTOMINOS"
"print(solution.display())"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "45085dd3",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAHgAAACgCAMAAADw11iiAAAAk1BMVEUAAACBwY3ac/hk0/mbAEoJ9QGTXJ7ydEoWUaeNs7AXWTtcDgONxtiUs2IrEdqBgtgbhHCs6SGq72YpD6d4r8iWYLJ1mXWi2op3zdOIlOALFnivsiUhhdoFzLH3PGk3RDY4tweuj5Rka49aRhpf1ElPVhqFkRlyJ7oUG+/958OetdD6VNMXulL7EKfxKRLFMco+FIFhhjlHAAABL0lEQVR4nO3OSVJCURQEUcNeOhUUBLEDsRdk/5tzVjWpeIMfd5i5gZMHh82O1HGzE3WqzpodAAMDA3eGz1Xi3IVKXILTQk8BAwMDV8CurxLsBirBQ9ULAQMDA1fA/WbmRmoQGoYuFTAwMHAFfNXsWo1C5sZqohLsgIGBgbvDNypx7lYZHocmIXNTBQwMDFwBu5lKsLtTCZ6raQgYGBi4Al6oWShxqXnoXgEDAwNXwIuQuaV6aPaonlSCHTAwMHB3+FkZXoZeVOIS7MytFDAwMHAF7NYqwe5VJXijViFgYGDgCnjdLHGpTehNAQMDA1fA780+1GezL/WtEuyAgYGBu8M/KnHuVyUuwc7cVgEDAwNXwG6nEuz+VIL3ahsCBgYGroB3zRKX2jcDBgYGLoD/ASi7eOqIz7E2AAAAAElFTkSuQmCC\n",
"text/plain": [
"<polyomino.solution.Solution at 0x6f59b5e0>"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"board = Irregular([(i, j) for i in range(0, 12) for j in range(0, 16)])\n",
"problem = board.tile_with_many(TETROMINOS['T'])\n",
"problem.solve()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a990b439",
"id": "ba1efa04",
"metadata": {},
"outputs": [],
"source": []
Expand Down
100 changes: 89 additions & 11 deletions examples/display_solutions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,106 @@
"execution_count": 1,
"id": "c5f94563",
"metadata": {},
"outputs": [],
"source": [
"from polyomino.board import Chessboard, Irregular\n",
"from polyomino.constant import TETROMINOS, ALL_PENTOMINOS"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "a990b439",
"metadata": {},
"outputs": [],
"source": [
"solution = Chessboard().tile_with(ALL_PENTOMINOS + [TETROMINOS['Square']]).solve()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "24061091",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAMAAAC5zwKfAAAAKlBMVEUAAADHAmpXhq27nv0P09O+aOhDO+yTXJ/3b0Je9l31av2rSvJGyVnRuL77hKSIAAAAYklEQVR4nO3Mtw3AMBAEQULekOq/XGXP5HCQ0udOAVOmMP+2CIWQMHmorBYh4TjhFnyzh8MiJMweertFSJg9PIXrI0LCccI7qLqG3rTwCISE2UNV97BZhIQjhtVSDSFh8vAFbS7Jkaszv9kAAAAASUVORK5CYII=\n",
"text/plain": [
"<polyomino.solution.Solution at 0x6f537fe8>"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"solution"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "076e18a7",
"metadata": {},
"outputs": [
{
"ename": "ModuleNotFoundError",
"evalue": "No module named 'polyomino'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m/tmp/ipykernel_11300/1925078410.py\u001b[0m in \u001b[0;36m<cell line: 1>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mpolyomino\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mboard\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mChessboard\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mpolyomino\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mconstant\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mTETROMINOS\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mALL_PENTOMINOS\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'polyomino'"
"name": "stdout",
"output_type": "stream",
"text": [
"+-+-+-+-+-+-+-+-+\n",
"| | | |\n",
"+ +-+-+-+-+-+ +\n",
"| | | |\n",
"+-+ +-+ +-+-+-+-+\n",
"| | | | | |\n",
"+ +-+-+-+ +-+-+ +\n",
"| | | |\n",
"+-+-+-+-+-+-+ + +\n",
"| | | | |\n",
"+-+ +-+-+ +-+-+-+\n",
"| | | | | | |\n",
"+ +-+ + +-+ +-+ +\n",
"| | | | | |\n",
"+ +-+ +-+ +-+ +\n",
"| | | | |\n",
"+-+-+-+-+-+-+-+-+\n"
]
}
],
"source": [
"from polyomino.board import Chessboard\n",
"from polyomino.constant import TETROMINOS, ALL_PENTOMINOS"
"print(solution.display())"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "45085dd3",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAHgAAACgCAMAAADw11iiAAAAk1BMVEUAAACBwY3ac/hk0/mbAEoJ9QGTXJ7ydEoWUaeNs7AXWTtcDgONxtiUs2IrEdqBgtgbhHCs6SGq72YpD6d4r8iWYLJ1mXWi2op3zdOIlOALFnivsiUhhdoFzLH3PGk3RDY4tweuj5Rka49aRhpf1ElPVhqFkRlyJ7oUG+/958OetdD6VNMXulL7EKfxKRLFMco+FIFhhjlHAAABL0lEQVR4nO3OSVJCURQEUcNeOhUUBLEDsRdk/5tzVjWpeIMfd5i5gZMHh82O1HGzE3WqzpodAAMDA3eGz1Xi3IVKXILTQk8BAwMDV8CurxLsBirBQ9ULAQMDA1fA/WbmRmoQGoYuFTAwMHAFfNXsWo1C5sZqohLsgIGBgbvDNypx7lYZHocmIXNTBQwMDFwBu5lKsLtTCZ6raQgYGBi4Al6oWShxqXnoXgEDAwNXwIuQuaV6aPaonlSCHTAwMHB3+FkZXoZeVOIS7MytFDAwMHAF7NYqwe5VJXijViFgYGDgCnjdLHGpTehNAQMDA1fA780+1GezL/WtEuyAgYGBu8M/KnHuVyUuwc7cVgEDAwNXwG6nEuz+VIL3ahsCBgYGroB3zRKX2jcDBgYGLoD/ASi7eOqIz7E2AAAAAElFTkSuQmCC\n",
"text/plain": [
"<polyomino.solution.Solution at 0x6f59b5e0>"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"board = Irregular([(i, j) for i in range(0, 12) for j in range(0, 16)])\n",
"problem = board.tile_with_many(TETROMINOS['T'])\n",
"problem.solve()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a990b439",
"id": "ba1efa04",
"metadata": {},
"outputs": [],
"source": []
Expand Down

0 comments on commit bd4cc4f

Please sign in to comment.