From bd4cc4fbf109582891ca01af138e5acb7f12fcee Mon Sep 17 00:00:00 2001 From: Jack Grahl Date: Sat, 11 Nov 2023 23:37:59 +0000 Subject: [PATCH] Save the notebook showing how to display solutions. --- .../display_solutions-checkpoint.ipynb | 100 ++++++++++++++++-- examples/display_solutions.ipynb | 100 ++++++++++++++++-- 2 files changed, 178 insertions(+), 22 deletions(-) diff --git a/examples/.ipynb_checkpoints/display_solutions-checkpoint.ipynb b/examples/.ipynb_checkpoints/display_solutions-checkpoint.ipynb index 9089314..fd47e8a 100644 --- a/examples/.ipynb_checkpoints/display_solutions-checkpoint.ipynb +++ b/examples/.ipynb_checkpoints/display_solutions-checkpoint.ipynb @@ -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": [ + "" + ] + }, + "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\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": [ + "" + ] + }, + "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": [] diff --git a/examples/display_solutions.ipynb b/examples/display_solutions.ipynb index 9089314..fd47e8a 100644 --- a/examples/display_solutions.ipynb +++ b/examples/display_solutions.ipynb @@ -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": [ + "" + ] + }, + "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\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": [ + "" + ] + }, + "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": []