{
 "metadata": {
  "name": "",
  "signature": "sha256:d0203b0f622d317f1ef81956dd65a2cba91aa9cf994a926eaebcc4c4eb7ee1c6"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Sol Golomb\u2019s Rectangle Puzzle"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "This problem was presented by Gary Antonik in his 14/4/14 New York Times [Numberplay column](http://wordplay.blogs.nytimes.com/2014/04/14/rectangle). \n",
      "\n",
      ">Say you\u2019re given the following challenge: create a set of five rectangles that have sides of length 1, 2, 3, 4, 5, 6, 7, 8, 9 and 10 units. You can combine sides in a variety of ways: for example, you could create a set of rectangles with dimensions 1 x 3, 2 x 4, 5 x 7, 6 x 8 and 9 x 10.\n",
      ">\n",
      ">1. How many different sets of five rectangles are possible?\n",
      ">\n",
      ">2. What are the maximum and minimum values for the total areas of the five rectangles?\n",
      "<p><b>Bonus Challenges</b><p>\n",
      ">\n",
      ">3. What other values for the total areas of the five rectangles are possible?\n",
      ">\n",
      ">4. Which sets of rectangles may be assembled to form a square?\n",
      "\n",
      "To me, these are interesting questions because, first, I have a (slight) personal connection to Solomon Golomb (my former colleague at USC) and to Nelson Blachman (the father of my colleague Nancy Blachman), who presented the problem to  Antonik, and second, I find it interesting that the problems span the range from mathematical to computational. I wonder how the way I look at the problems compares to others who have a different mix of these two disciplines."
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "1. How many different sets of five rectangles are possible?"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "This is a basic [combinatorics](http://en.wikipedia.org/wiki/Combinatorics) or counting problem. I will present *three* methods to count the sets. (Hopefully they will give the same answer.) The example set given in the problem was\n",
      "\n",
      "> {1 &times; 3, 2 &times; 4, 5 &times; 7, 6 &times; 8, 9 &times; 10}\n",
      "    \n",
      "and in general it would be\n",
      "\n",
      "> {A &times; B, C &times; D, E &times; F, G &times; H, I &times; J}\n",
      "\n",
      "The question is: how many distinct ways can we assign values to the variables A through J?\n",
      "    \n",
      "**Method 1: Count all permutations and divide by repetitions:** There are 10 variables to be filled, so there are 10! = 3628800 permutations.  But if we fill the first two variables with 1 &times; 3, that is the same rectangle as 3 &times; 1. So divide 10! by 2<sup>5</sup> to account for the fact that each of 5 rectangles can appear 2 ways.  Similarly, if we fill A and B with 1 &times; 3, that yields the same set as if we filled C and D with 1 &times; 3.  So divide again by 5! (the number of permutations of 5 things) to account for this.\n",
      "That gives us <a href=\"https://www.google.com/search?ie=UTF-8#q=10!+%2F+2%5E5+/+5!\">10! / 2<sup>5</sup> / 5!</a> = 945.  (It is always gratifying when this \"count and divide\" method comes out to a whole number.)\n",
      "\n",
      "**Method 2: Count without repetitions**: The example set is presented in [lexicographical order](http://en.wikipedia.org/wiki/Lexicographical_order): in each rectangle the smaller component is listed first, and in the set, the rectangles with smaller first components are listed first.  An alternate to \"count and divide\" is to count directly how many sets there are in lexicographical order.  We'll work from left to right.  How many choices are there for variable A?  Only one: A must always be 1, because we agreed that the smallest number comes first. Then, given A, there are 9 remaining choices for B.  For C, given A and B, there is again only one choice: C must be the smallest of the remaining 8 numbers (it will be 3 if the first rectangle was 1 &times; 2; otherwise it will be 2, but either way there is only one choice).  That leaves 7 choices for D, 5 for F, 3 for H and 1 for J. And 9 &times; 7 &times; 5 &times; 3 &times; 1 = 945. (It is always gratifying when two methods give the same answer.)\n",
      "          \n",
      "**Method 3: Write a program to enumerate the sets:** We'll represent the 1 &times; 3 rectangle as the tuple `(1, 3)` and the example set of rectangles as the set\n",
      "\n",
      "> {(1, 3), (2, 4), (5, 7), (6, 8), (9, 10)}\n",
      "\n",
      "To generate all the sets of rectangles, we'll follow method 2: given a set of sides, first make all possible rectangles `(A, B)` where `A` is the shortest side, and `B` ranges over all the other sides.  For each of `(A, B)` rectangle, consider all possible `(C, D)` rectangles, and so on. This is easy to write out if we know there will be exactly 5 rectangles in a set:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "def sets_of_rectangles(sides):\n",
      "    \"Given exactly 10 sides, yield all sets of rectangles that can be made from them.\"\n",
      "    A = min(sides)\n",
      "    for (A, B) in each_rectangle(sides):\n",
      "        for (C, D) in each_rectangle(sides - {A, B}):\n",
      "            for (E, F) in each_rectangle(sides - {A, B, C, D}):\n",
      "                for (G, H) in each_rectangle(sides - {A, B, C, D, E, F}):\n",
      "                    for (I, J) in each_rectangle(sides - {A, B, C, D, E, F, G, H}):\n",
      "                        yield {(A, B), (C, D), (E, F), (G, H), (I, J)}\n",
      "                        \n",
      "def each_rectangle(sides):\n",
      "    \"Yield all (A, B) pairs, where A is minimum of sides, and B ranges over all other sides.\"\n",
      "    A = min(sides)\n",
      "    for B in (sides - {A}):\n",
      "        yield (A, B)    "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 100
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "sides = set(range(1, 11))\n",
      "sets = list(sets_of_rectangles(sides))\n",
      "len(sets)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 101,
       "text": [
        "945"
       ]
      }
     ],
     "prompt_number": 101
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "(Gratifying that once again we get the same answer.)  But I don't like the fact that the code only works for exactly 10 sides, and it violates the \"[don't repeat yourself](http://en.wikipedia.org/wiki/Don't_repeat_yourself)\" maxim.  So let's convert the nested-iterated algorithm into a *recursive* algorithm that chooses the first rectangle (in the same way as before), but then recursively solves for the remaining sides and unions the set of rectangles from the remaining sides with the first rectangle.  (Note we have to also correctly handle the case when there are no sides; then there is one way to make a set of rectangles: the empty set.)"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "def sets_of_rectangles(sides):\n",
      "    \"Given a set of sides, yield all sets of rectangles that can be made from sides.\"\n",
      "    if sides:\n",
      "        A = min(sides)\n",
      "        for B in (sides - {A}):\n",
      "            for rest in sets_of_rectangles(sides - {A, B}):\n",
      "                yield {(A, B)}.union(rest)\n",
      "    else:\n",
      "        yield set()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 102
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# For example, with 6 sides:\n",
      "list(sets_of_rectangles({1, 2, 3, 4, 5, 6}))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 103,
       "text": [
        "[{(1, 2), (3, 4), (5, 6)},\n",
        " {(1, 2), (3, 5), (4, 6)},\n",
        " {(1, 2), (3, 6), (4, 5)},\n",
        " {(1, 3), (2, 4), (5, 6)},\n",
        " {(1, 3), (2, 5), (4, 6)},\n",
        " {(1, 3), (2, 6), (4, 5)},\n",
        " {(1, 4), (2, 3), (5, 6)},\n",
        " {(1, 4), (2, 5), (3, 6)},\n",
        " {(1, 4), (2, 6), (3, 5)},\n",
        " {(1, 5), (2, 3), (4, 6)},\n",
        " {(1, 5), (2, 4), (3, 6)},\n",
        " {(1, 5), (2, 6), (3, 4)},\n",
        " {(1, 6), (2, 3), (4, 5)},\n",
        " {(1, 6), (2, 4), (3, 5)},\n",
        " {(1, 6), (2, 5), (3, 4)}]"
       ]
      }
     ],
     "prompt_number": 103
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Reaffirm the answer with 10 sides\n",
      "sets = list(sets_of_rectangles(sides))\n",
      "len(sets)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 104,
       "text": [
        "945"
       ]
      }
     ],
     "prompt_number": 104
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "I don't want to print all 945 sets, but let's peek at every 100th one:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "sets[::100]"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 105,
       "text": [
        "[{(1, 2), (3, 4), (5, 8), (6, 9), (7, 10)},\n",
        " {(1, 2), (3, 10), (4, 6), (5, 9), (7, 8)},\n",
        " {(1, 3), (2, 10), (4, 9), (5, 7), (6, 8)},\n",
        " {(1, 4), (2, 10), (3, 8), (5, 9), (6, 7)},\n",
        " {(1, 5), (2, 9), (3, 6), (4, 10), (7, 8)},\n",
        " {(1, 6), (2, 9), (3, 10), (4, 7), (5, 8)},\n",
        " {(1, 7), (2, 9), (3, 8), (4, 10), (5, 6)},\n",
        " {(1, 8), (2, 7), (3, 5), (4, 10), (6, 9)},\n",
        " {(1, 9), (2, 7), (3, 10), (4, 6), (5, 8)},\n",
        " {(1, 10), (2, 7), (3, 8), (4, 9), (5, 6)}]"
       ]
      }
     ],
     "prompt_number": 105
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "2. What are the maximum and minimum values for the total areas of the five rectangles?"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "-"
      }
     },
     "source": [
      "I think I know this one, but I'm not completely sure.  I know that a rectangle with a fixed perimeter has maximum area when it is a square. My guess is that the maximum total area occurs when each rectangle is *almost* square: a 9 &times; 10 rectangle; 7 &times; 8; and so on.  So that would give us a maximum area of:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "(1 * 2) + (3 * 4) + (5 * 6) + (7 * 8) + (9  * 10)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 106,
       "text": [
        "190"
       ]
      }
     ],
     "prompt_number": 106
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "And the minimum area should be when the rectangles deviate the most from squares: a 1 &times; 10, and so on:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "(1 * 10) + (2 * 9) + (3 * 8) + (4 * 7) + (5 * 6)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 107,
       "text": [
        "110"
       ]
      }
     ],
     "prompt_number": 107
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Since I am not sure, I will double check by computing the set of all possible areas and then asking for the min and max of the set:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "def area(rectangle): (w, h) = rectangle; return w * h\n",
      "\n",
      "def total_area(rectangles): return sum(area(r) for r in rectangles)\n",
      "\n",
      "areas = {total_area(s) for s in sets}"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 108
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "max(areas)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 109,
       "text": [
        "190"
       ]
      }
     ],
     "prompt_number": 109
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "min(areas)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 110,
       "text": [
        "110"
       ]
      }
     ],
     "prompt_number": 110
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "This verifies that the maximum and minimum are what I thought they were. But I still don't think I completely understand the situation.  For example, suppose there are *N* sides that are not necessarily consecutive integers.  Will the maximum total area always be formed by combining the two biggest sides, and so on?"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "3. What other values for the total areas of the five rectangles are possible?"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "I have no idea how to figure this out mathematically from first principles, but it is easy to compute with the code we already have:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "print sorted(areas) "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "[110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 177, 178, 179, 180, 181, 182, 183, 184, 186, 187, 190]\n"
       ]
      }
     ],
     "prompt_number": 111
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Is there a more succint way to describe these values?"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "set(range(110, 191)) - areas"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 112,
       "text": [
        "{176, 185, 188, 189}"
       ]
      }
     ],
     "prompt_number": 112
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Yes: All the integers between 110 and 190 inclusive, except 176, 185, 188, and 189."
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "4. Which sets of rectangles may be assembled to form a square?"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "The only way I can think about this is to write a program; I don't see any way to work it out by hand.  I do know that the total area will have to be a perfect square, and that in the range of areas (110 to 190) the only perfect squares are 11<sup>2</sup> = 121, 12<sup>2</sup> = 144, and 13<sup>2</sup> = 169. We can find the rectangle sets that have a perfect square as their total area:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "[s for s in sets if total_area(s) in {121, 144, 169}]"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 113,
       "text": [
        "[{(1, 2), (3, 5), (4, 9), (6, 10), (7, 8)},\n",
        " {(1, 2), (3, 7), (4, 9), (5, 6), (8, 10)},\n",
        " {(1, 2), (3, 7), (4, 6), (5, 10), (8, 9)},\n",
        " {(1, 2), (3, 8), (4, 5), (6, 10), (7, 9)},\n",
        " {(1, 3), (2, 5), (4, 8), (6, 9), (7, 10)},\n",
        " {(1, 3), (2, 7), (4, 8), (5, 6), (9, 10)},\n",
        " {(1, 3), (2, 7), (4, 5), (6, 10), (8, 9)},\n",
        " {(1, 3), (2, 9), (4, 10), (5, 7), (6, 8)},\n",
        " {(1, 3), (2, 10), (4, 8), (5, 7), (6, 9)},\n",
        " {(1, 3), (2, 10), (4, 7), (5, 9), (6, 8)},\n",
        " {(1, 4), (2, 5), (3, 7), (6, 9), (8, 10)},\n",
        " {(1, 5), (2, 3), (4, 9), (6, 7), (8, 10)},\n",
        " {(1, 5), (2, 4), (3, 8), (6, 7), (9, 10)},\n",
        " {(1, 5), (2, 6), (3, 8), (4, 10), (7, 9)},\n",
        " {(1, 5), (2, 7), (3, 4), (6, 8), (9, 10)},\n",
        " {(1, 6), (2, 3), (4, 8), (5, 7), (9, 10)},\n",
        " {(1, 6), (2, 9), (3, 10), (4, 8), (5, 7)},\n",
        " {(1, 6), (2, 10), (3, 8), (4, 9), (5, 7)},\n",
        " {(1, 6), (2, 10), (3, 9), (4, 7), (5, 8)},\n",
        " {(1, 7), (2, 4), (3, 8), (5, 9), (6, 10)},\n",
        " {(1, 7), (2, 9), (3, 5), (4, 6), (8, 10)},\n",
        " {(1, 7), (2, 10), (3, 6), (4, 9), (5, 8)},\n",
        " {(1, 8), (2, 6), (3, 10), (4, 9), (5, 7)},\n",
        " {(1, 8), (2, 7), (3, 10), (4, 6), (5, 9)},\n",
        " {(1, 8), (2, 9), (3, 7), (4, 6), (5, 10)},\n",
        " {(1, 8), (2, 10), (3, 5), (4, 9), (6, 7)},\n",
        " {(1, 9), (2, 5), (3, 7), (4, 6), (8, 10)},\n",
        " {(1, 9), (2, 6), (3, 5), (4, 7), (8, 10)},\n",
        " {(1, 9), (2, 7), (3, 8), (4, 6), (5, 10)},\n",
        " {(1, 9), (2, 7), (3, 10), (4, 5), (6, 8)},\n",
        " {(1, 9), (2, 7), (3, 6), (4, 10), (5, 8)},\n",
        " {(1, 9), (2, 8), (3, 6), (4, 7), (5, 10)},\n",
        " {(1, 10), (2, 4), (3, 5), (6, 8), (7, 9)},\n",
        " {(1, 10), (2, 5), (3, 9), (4, 8), (6, 7)},\n",
        " {(1, 10), (2, 8), (3, 7), (4, 5), (6, 9)}]"
       ]
      }
     ],
     "prompt_number": 113
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "len(_)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 114,
       "text": [
        "35"
       ]
      }
     ],
     "prompt_number": 114
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "So 35 out of 945 rectangle sets *might* be assembled into a square; we don't know yet. Also I would like to see *how* the rectangles are packed into the square, not just *which* sets can be packed, so I'll need a visual display of rectangles packed into a square. To start, I'll represent a *Grid* as a two-dimensional array: a list of rows, each of which is a list of cells, with the idea that each cell will be covered by a rectangle. We'll initialize each cell to be empty:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "empty = (0, 0)\n",
      "\n",
      "def Grid(width, height):\n",
      "    return [[empty for col in range(width)] for row in range(height)]\n",
      "\n",
      "def Square(size): return Grid(size, size)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 115
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "Square(5)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 116,
       "text": [
        "[[(0, 0), (0, 0), (0, 0), (0, 0), (0, 0)],\n",
        " [(0, 0), (0, 0), (0, 0), (0, 0), (0, 0)],\n",
        " [(0, 0), (0, 0), (0, 0), (0, 0), (0, 0)],\n",
        " [(0, 0), (0, 0), (0, 0), (0, 0), (0, 0)],\n",
        " [(0, 0), (0, 0), (0, 0), (0, 0), (0, 0)]]"
       ]
      }
     ],
     "prompt_number": 116
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Let's make a function to place a rectangle onto a grid.  `place_rectangle_at` places a rectangle of width *w* and height *h* onto a grid at position (x<sub>0</sub>, y<sub>0</sub>).  If the rectangle overlaps a non-empty cell, or goes off the grid, we return `None` to indicate that this is not a legal placement. If the rectangle does fit, we return a new grid with any old rectangles plus the new one (we do not modify the old grid):"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "def place_rectangle_at(rect, grid, pos):\n",
      "    \"\"\"Place the rectangle of size (w, h) onto grid at position (x0, y0).\n",
      "    Return a new grid, or None if the rectangle cannot be placed.\"\"\"\n",
      "    (w, h) = rect\n",
      "    (x0, y0) = pos\n",
      "    newgrid = map(list, grid) # make a copy\n",
      "    try:\n",
      "        for x in range(x0, x0+w):\n",
      "            for y in range(y0, y0+h):\n",
      "                if newgrid[y][x] is not empty:\n",
      "                    return None   \n",
      "                newgrid[y][x] = rect\n",
      "        return newgrid\n",
      "    except IndexError: # went off the grid\n",
      "        return None"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 117
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Place a 3 x 4 rectangle on a square grid, 2 cells over and 1 down:\n",
      "place_rectangle_at((3, 4), Square(5), (2, 1))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 118,
       "text": [
        "[[(0, 0), (0, 0), (0, 0), (0, 0), (0, 0)],\n",
        " [(0, 0), (0, 0), (3, 4), (3, 4), (3, 4)],\n",
        " [(0, 0), (0, 0), (3, 4), (3, 4), (3, 4)],\n",
        " [(0, 0), (0, 0), (3, 4), (3, 4), (3, 4)],\n",
        " [(0, 0), (0, 0), (3, 4), (3, 4), (3, 4)]]"
       ]
      }
     ],
     "prompt_number": 118
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Place two rectangles on a grid\n",
      "grid2 = place_rectangle_at((3, 4), Square(5), (2, 1))\n",
      "grid3 = place_rectangle_at((2, 5), grid2, (0, 0))\n",
      "grid3"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 119,
       "text": [
        "[[(2, 5), (2, 5), (0, 0), (0, 0), (0, 0)],\n",
        " [(2, 5), (2, 5), (3, 4), (3, 4), (3, 4)],\n",
        " [(2, 5), (2, 5), (3, 4), (3, 4), (3, 4)],\n",
        " [(2, 5), (2, 5), (3, 4), (3, 4), (3, 4)],\n",
        " [(2, 5), (2, 5), (3, 4), (3, 4), (3, 4)]]"
       ]
      }
     ],
     "prompt_number": 119
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Now try to place a third rectangle that does not fit; should fail\n",
      "print place_rectangle_at((6, 1), grid3, (0, 2))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "None\n"
       ]
      }
     ],
     "prompt_number": 120
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Now we need a strategy for packing a set of rectangles onto a grid.  I know that many variants of [bin packing problems](http://en.wikipedia.org/wiki/Bin_packing_problem) are NP-hard, but we only have 5 rectangles, so it should be easy: just exhaustively try each rectangle in each possible position in both possible orientations (horizontal and vertical). But placing rectangles is commutative, so we can do this two ways:\n",
      "\n",
      "> Way 1: Considering the rectangles in a fixed order, try every possible position for each rectangle.\n",
      "\n",
      "or\n",
      "\n",
      "> Way 2: Considering the positions in a fixed order, try every possible rectangle for each position.\n",
      "\n",
      "In Way 1, we could pre-sort the rectangles (say, biggest first).  Then we try to put the biggest rectangle in all possible positions on the grid, and for each position that fits, try putting the second biggest rectangle in all remaining positions, and so on.  \n",
      "\n",
      "In Way 2, we consider the positions in some fixed order; say top-to-bottom, left-to right.  Take the first empty position (the upper left corner).  Try putting each of the rectangles there, and for each one that fits, try the next empty position, and consider all possible rectangles to go there, and so on.\n",
      "\n",
      "Which way is better?  I'm not sure&mdash;let us calculate. As a wild guess, assume there are on average about 10 ways to place a rectangle on a grid.  Then Way 1 will look at 10<sup>5</sup> = 100,000 combinations.  For Way 2, there are only 5! = 120 permutations of rectangles, and each rectangle can go either horizontaly or verticaly, so that's 5! &times; 2<sup>5</sup> = 3840.  Since 3840 &lt; 100,000, I'll go with Way 2.  Here is a more precise description:\n",
      "\n",
      "> Way 2: To **pack** a set of rectangles onto a grid, find the first empty cell on the grid.  Try in turn to place each rectangle (in either orientation) at that position. For each one that fits, try to recursively **pack** the remaining rectangles, and return the resulting grid if one of these recursive calls succeeds.  If none succeeds, return None.  *Details:* If there are no rectangles to pack, the solution is the original grid.  If the grid is illegal, we can't place anything on it, so return None. The order we choose for the first empty cell is arbitrary; we will go top-to-bottom, left-to-right."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "def pack(rectangles, grid):\n",
      "    \"\"\"Find a way to pack all rectangles onto grid and return the packed grid,\n",
      "    or return None if not possible.\"\"\"\n",
      "    if not rectangles:\n",
      "        return grid # Placing no rectangles give you the original grid\n",
      "    elif not grid:\n",
      "        return None  # Can't put rectangles on an illegal grid\n",
      "    else:\n",
      "        pos = first_empty_cell(grid)\n",
      "        for (w, h) in rectangles: # for each rectangle\n",
      "            for rect in [(w, h), (h, w)]: # in either orientation\n",
      "                grid2 = place_rectangle_at(rect, grid, pos)\n",
      "                solution = pack(rectangles - {(w, h)}, grid2)\n",
      "                if solution:\n",
      "                    return solution\n",
      "        return None\n",
      "    \n",
      "def first_empty_cell(grid):\n",
      "    \"The uppermost, leftmost empty cell position on grid.\"\n",
      "    for (y, row) in enumerate(grid):\n",
      "        for (x, cell) in enumerate(row):\n",
      "            if cell is empty:\n",
      "                return (x, y)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 121
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Let's try a simple example that I know will fit:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "pack({(1, 3), (2, 5), (3, 4)}, Square(5))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 122,
       "text": [
        "[[(2, 5), (2, 5), (3, 1), (3, 1), (3, 1)],\n",
        " [(2, 5), (2, 5), (3, 4), (3, 4), (3, 4)],\n",
        " [(2, 5), (2, 5), (3, 4), (3, 4), (3, 4)],\n",
        " [(2, 5), (2, 5), (3, 4), (3, 4), (3, 4)],\n",
        " [(2, 5), (2, 5), (3, 4), (3, 4), (3, 4)]]"
       ]
      }
     ],
     "prompt_number": 122
    },
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Colored Rectangles"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "The grid output does show how the rectangles are packed into the square, but the output is hard to read. It would be nicer to have a graphical display of colored rectangles.  IPython has an add-on module called [ipythonblocks](http://ipythonblocks.org/) that does this. (If you are running this notebook in your copy of IPython notebook, you may need to do the shell command `\"pip install ipythonblocks\"` or `\"easy-install ipythonblocks\"`.)  I will define the function `show` which takes a grid and displays it as a matrix of colored rectangles. "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import ipythonblocks\n",
      "\n",
      "def show(grid):\n",
      "    \"Convert a python grid into an ipythonblocks BlockGrid and show it.\"\n",
      "    (w, h) = (len(grid[0]), len(grid))\n",
      "    bg = ipythonblocks.BlockGrid(w, h)\n",
      "    for x in range(w):\n",
      "        for y in range(h):\n",
      "            bg[y,x] = color(grid[y][x])\n",
      "    bg.show()\n",
      "            \n",
      "def color(rect):\n",
      "    \"Determine a color for a rectangle.\"\n",
      "    # Base the color on the length of the sides of the rectangle\n",
      "    # Choose R,G,B values to give rectangles different colors\n",
      "    light = 240 # R,G,B = 240,240,240 is a light grey\n",
      "    short, long = sorted(rect) # Find the short and long sides\n",
      "    R, G, B = light-24*short, light-24*long, light-(50*(long%3) + 70*(short%3))\n",
      "    return (R, G, B)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 123
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "show(pack({(1, 3), (2, 5), (3, 4)}, Square(5)))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "html": [
        "<style type=\"text/css\">table.blockgrid {border: none;} .blockgrid tr {border: none;} .blockgrid td {padding: 0px;} #blocksa32cd308-fa82-4aee-86c3-0a7cc21131e2 td {border: 1px solid white;}</style><table id=\"blocksa32cd308-fa82-4aee-86c3-0a7cc21131e2\" class=\"blockgrid\"><tbody><tr><td title=\"Index: [0, 0]&#10;Color: (192, 120, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 120, 0);\"></td><td title=\"Index: [0, 1]&#10;Color: (192, 120, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 120, 0);\"></td><td title=\"Index: [0, 2]&#10;Color: (216, 168, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(216, 168, 170);\"></td><td title=\"Index: [0, 3]&#10;Color: (216, 168, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(216, 168, 170);\"></td><td title=\"Index: [0, 4]&#10;Color: (216, 168, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(216, 168, 170);\"></td></tr><tr><td title=\"Index: [1, 0]&#10;Color: (192, 120, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 120, 0);\"></td><td title=\"Index: [1, 1]&#10;Color: (192, 120, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 120, 0);\"></td><td title=\"Index: [1, 2]&#10;Color: (168, 144, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 144, 190);\"></td><td title=\"Index: [1, 3]&#10;Color: (168, 144, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 144, 190);\"></td><td title=\"Index: [1, 4]&#10;Color: (168, 144, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 144, 190);\"></td></tr><tr><td title=\"Index: [2, 0]&#10;Color: (192, 120, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 120, 0);\"></td><td title=\"Index: [2, 1]&#10;Color: (192, 120, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 120, 0);\"></td><td title=\"Index: [2, 2]&#10;Color: (168, 144, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 144, 190);\"></td><td title=\"Index: [2, 3]&#10;Color: (168, 144, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 144, 190);\"></td><td title=\"Index: [2, 4]&#10;Color: (168, 144, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 144, 190);\"></td></tr><tr><td title=\"Index: [3, 0]&#10;Color: (192, 120, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 120, 0);\"></td><td title=\"Index: [3, 1]&#10;Color: (192, 120, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 120, 0);\"></td><td title=\"Index: [3, 2]&#10;Color: (168, 144, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 144, 190);\"></td><td title=\"Index: [3, 3]&#10;Color: (168, 144, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 144, 190);\"></td><td title=\"Index: [3, 4]&#10;Color: (168, 144, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 144, 190);\"></td></tr><tr><td title=\"Index: [4, 0]&#10;Color: (192, 120, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 120, 0);\"></td><td title=\"Index: [4, 1]&#10;Color: (192, 120, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 120, 0);\"></td><td title=\"Index: [4, 2]&#10;Color: (168, 144, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 144, 190);\"></td><td title=\"Index: [4, 3]&#10;Color: (168, 144, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 144, 190);\"></td><td title=\"Index: [4, 4]&#10;Color: (168, 144, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 144, 190);\"></td></tr></tbody></table>"
       ],
       "metadata": {},
       "output_type": "display_data",
       "text": [
        "<IPython.core.display.HTML at 0x10abec350>"
       ]
      }
     ],
     "prompt_number": 124
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "That's much easier to look at! Now we can create a function to show all the packable sets of rectangles:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "def show_packable(sets):\n",
      "    \"Given a sequence of sets of rectangles, show the ones that can be packed into a square.\"\n",
      "    for rectangles in sets:\n",
      "        A = total_area(rectangles)\n",
      "        side = int(A ** 0.5)\n",
      "        if side ** 2 == A:\n",
      "            grid = pack(rectangles, Square(side))\n",
      "            if grid:\n",
      "                show(grid)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 125
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%time show_packable(sets)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "html": [
        "<style type=\"text/css\">table.blockgrid {border: none;} .blockgrid tr {border: none;} .blockgrid td {padding: 0px;} #blocks0f1b57e0-3c22-405f-9f1d-8077be9b5200 td {border: 1px solid white;}</style><table id=\"blocks0f1b57e0-3c22-405f-9f1d-8077be9b5200\" class=\"blockgrid\"><tbody><tr><td title=\"Index: [0, 0]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [0, 1]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [0, 2]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [0, 3]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [0, 4]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [0, 5]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [0, 6]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [0, 7]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [0, 8]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [0, 9]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [0, 10]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [0, 11]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [0, 12]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td></tr><tr><td title=\"Index: [1, 0]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [1, 1]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [1, 2]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [1, 3]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [1, 4]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [1, 5]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [1, 6]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [1, 7]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [1, 8]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [1, 9]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [1, 10]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [1, 11]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [1, 12]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td></tr><tr><td title=\"Index: [2, 0]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [2, 1]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [2, 2]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [2, 3]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [2, 4]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [2, 5]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [2, 6]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [2, 7]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [2, 8]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [2, 9]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [2, 10]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [2, 11]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [2, 12]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td></tr><tr><td title=\"Index: [3, 0]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [3, 1]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [3, 2]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [3, 3]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [3, 4]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [3, 5]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [3, 6]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [3, 7]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [3, 8]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [3, 9]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [3, 10]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [3, 11]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [3, 12]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td></tr><tr><td title=\"Index: [4, 0]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [4, 1]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [4, 2]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [4, 3]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [4, 4]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [4, 5]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [4, 6]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [4, 7]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [4, 8]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [4, 9]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [4, 10]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [4, 11]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [4, 12]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td></tr><tr><td title=\"Index: [5, 0]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [5, 1]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [5, 2]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [5, 3]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [5, 4]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [5, 5]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [5, 6]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [5, 7]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [5, 8]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [5, 9]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [5, 10]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [5, 11]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [5, 12]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td></tr><tr><td title=\"Index: [6, 0]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [6, 1]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [6, 2]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [6, 3]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [6, 4]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [6, 5]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [6, 6]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [6, 7]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [6, 8]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [6, 9]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [6, 10]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [6, 11]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [6, 12]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td></tr><tr><td title=\"Index: [7, 0]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [7, 1]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [7, 2]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [7, 3]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [7, 4]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [7, 5]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [7, 6]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [7, 7]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [7, 8]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [7, 9]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [7, 10]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [7, 11]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [7, 12]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td></tr><tr><td title=\"Index: [8, 0]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [8, 1]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [8, 2]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [8, 3]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [8, 4]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [8, 5]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [8, 6]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [8, 7]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [8, 8]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [8, 9]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [8, 10]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [8, 11]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [8, 12]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td></tr><tr><td title=\"Index: [9, 0]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [9, 1]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [9, 2]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [9, 3]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [9, 4]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [9, 5]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [9, 6]&#10;Color: (216, 192, 70)\" style=\"width: 20px; height: 20px;background-color: rgb(216, 192, 70);\"></td><td title=\"Index: [9, 7]&#10;Color: (216, 192, 70)\" style=\"width: 20px; height: 20px;background-color: rgb(216, 192, 70);\"></td><td title=\"Index: [9, 8]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [9, 9]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [9, 10]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [9, 11]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [9, 12]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td></tr><tr><td title=\"Index: [10, 0]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [10, 1]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [10, 2]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [10, 3]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [10, 4]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [10, 5]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [10, 6]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [10, 7]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [10, 8]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [10, 9]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [10, 10]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [10, 11]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [10, 12]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td></tr><tr><td title=\"Index: [11, 0]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [11, 1]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [11, 2]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [11, 3]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [11, 4]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [11, 5]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [11, 6]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [11, 7]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [11, 8]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [11, 9]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [11, 10]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [11, 11]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [11, 12]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td></tr><tr><td title=\"Index: [12, 0]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [12, 1]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [12, 2]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [12, 3]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [12, 4]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [12, 5]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [12, 6]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [12, 7]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [12, 8]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [12, 9]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [12, 10]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [12, 11]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [12, 12]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td></tr></tbody></table>"
       ],
       "metadata": {},
       "output_type": "display_data",
       "text": [
        "<IPython.core.display.HTML at 0x10bc751d0>"
       ]
      },
      {
       "html": [
        "<style type=\"text/css\">table.blockgrid {border: none;} .blockgrid tr {border: none;} .blockgrid td {padding: 0px;} #blocks934bf859-a2bc-4677-9fba-cf01fe5d7802 td {border: 1px solid white;}</style><table id=\"blocks934bf859-a2bc-4677-9fba-cf01fe5d7802\" class=\"blockgrid\"><tbody><tr><td title=\"Index: [0, 0]&#10;Color: (168, 48, 140)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 48, 140);\"></td><td title=\"Index: [0, 1]&#10;Color: (168, 48, 140)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 48, 140);\"></td><td title=\"Index: [0, 2]&#10;Color: (168, 48, 140)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 48, 140);\"></td><td title=\"Index: [0, 3]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [0, 4]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [0, 5]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [0, 6]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [0, 7]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [0, 8]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [0, 9]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [0, 10]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [0, 11]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [0, 12]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td></tr><tr><td title=\"Index: [1, 0]&#10;Color: (168, 48, 140)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 48, 140);\"></td><td title=\"Index: [1, 1]&#10;Color: (168, 48, 140)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 48, 140);\"></td><td title=\"Index: [1, 2]&#10;Color: (168, 48, 140)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 48, 140);\"></td><td title=\"Index: [1, 3]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [1, 4]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [1, 5]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [1, 6]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [1, 7]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [1, 8]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [1, 9]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [1, 10]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [1, 11]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [1, 12]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td></tr><tr><td title=\"Index: [2, 0]&#10;Color: (168, 48, 140)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 48, 140);\"></td><td title=\"Index: [2, 1]&#10;Color: (168, 48, 140)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 48, 140);\"></td><td title=\"Index: [2, 2]&#10;Color: (168, 48, 140)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 48, 140);\"></td><td title=\"Index: [2, 3]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [2, 4]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [2, 5]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [2, 6]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [2, 7]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [2, 8]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [2, 9]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [2, 10]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [2, 11]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [2, 12]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td></tr><tr><td title=\"Index: [3, 0]&#10;Color: (168, 48, 140)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 48, 140);\"></td><td title=\"Index: [3, 1]&#10;Color: (168, 48, 140)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 48, 140);\"></td><td title=\"Index: [3, 2]&#10;Color: (168, 48, 140)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 48, 140);\"></td><td title=\"Index: [3, 3]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [3, 4]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [3, 5]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [3, 6]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [3, 7]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [3, 8]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [3, 9]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [3, 10]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [3, 11]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [3, 12]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td></tr><tr><td title=\"Index: [4, 0]&#10;Color: (168, 48, 140)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 48, 140);\"></td><td title=\"Index: [4, 1]&#10;Color: (168, 48, 140)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 48, 140);\"></td><td title=\"Index: [4, 2]&#10;Color: (168, 48, 140)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 48, 140);\"></td><td title=\"Index: [4, 3]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [4, 4]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [4, 5]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [4, 6]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [4, 7]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [4, 8]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [4, 9]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [4, 10]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [4, 11]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [4, 12]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td></tr><tr><td title=\"Index: [5, 0]&#10;Color: (168, 48, 140)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 48, 140);\"></td><td title=\"Index: [5, 1]&#10;Color: (168, 48, 140)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 48, 140);\"></td><td title=\"Index: [5, 2]&#10;Color: (168, 48, 140)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 48, 140);\"></td><td title=\"Index: [5, 3]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [5, 4]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [5, 5]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [5, 6]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [5, 7]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [5, 8]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [5, 9]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [5, 10]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [5, 11]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td><td title=\"Index: [5, 12]&#10;Color: (96, 0, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(96, 0, 190);\"></td></tr><tr><td title=\"Index: [6, 0]&#10;Color: (168, 48, 140)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 48, 140);\"></td><td title=\"Index: [6, 1]&#10;Color: (168, 48, 140)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 48, 140);\"></td><td title=\"Index: [6, 2]&#10;Color: (168, 48, 140)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 48, 140);\"></td><td title=\"Index: [6, 3]&#10;Color: (216, 192, 70)\" style=\"width: 20px; height: 20px;background-color: rgb(216, 192, 70);\"></td><td title=\"Index: [6, 4]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [6, 5]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [6, 6]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [6, 7]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [6, 8]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [6, 9]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [6, 10]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [6, 11]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [6, 12]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td></tr><tr><td title=\"Index: [7, 0]&#10;Color: (168, 48, 140)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 48, 140);\"></td><td title=\"Index: [7, 1]&#10;Color: (168, 48, 140)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 48, 140);\"></td><td title=\"Index: [7, 2]&#10;Color: (168, 48, 140)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 48, 140);\"></td><td title=\"Index: [7, 3]&#10;Color: (216, 192, 70)\" style=\"width: 20px; height: 20px;background-color: rgb(216, 192, 70);\"></td><td title=\"Index: [7, 4]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [7, 5]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [7, 6]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [7, 7]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [7, 8]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [7, 9]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [7, 10]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [7, 11]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [7, 12]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td></tr><tr><td title=\"Index: [8, 0]&#10;Color: (144, 120, 70)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 120, 70);\"></td><td title=\"Index: [8, 1]&#10;Color: (144, 120, 70)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 120, 70);\"></td><td title=\"Index: [8, 2]&#10;Color: (144, 120, 70)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 120, 70);\"></td><td title=\"Index: [8, 3]&#10;Color: (144, 120, 70)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 120, 70);\"></td><td title=\"Index: [8, 4]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [8, 5]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [8, 6]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [8, 7]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [8, 8]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [8, 9]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [8, 10]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [8, 11]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [8, 12]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td></tr><tr><td title=\"Index: [9, 0]&#10;Color: (144, 120, 70)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 120, 70);\"></td><td title=\"Index: [9, 1]&#10;Color: (144, 120, 70)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 120, 70);\"></td><td title=\"Index: [9, 2]&#10;Color: (144, 120, 70)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 120, 70);\"></td><td title=\"Index: [9, 3]&#10;Color: (144, 120, 70)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 120, 70);\"></td><td title=\"Index: [9, 4]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [9, 5]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [9, 6]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [9, 7]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [9, 8]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [9, 9]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [9, 10]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [9, 11]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [9, 12]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td></tr><tr><td title=\"Index: [10, 0]&#10;Color: (144, 120, 70)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 120, 70);\"></td><td title=\"Index: [10, 1]&#10;Color: (144, 120, 70)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 120, 70);\"></td><td title=\"Index: [10, 2]&#10;Color: (144, 120, 70)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 120, 70);\"></td><td title=\"Index: [10, 3]&#10;Color: (144, 120, 70)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 120, 70);\"></td><td title=\"Index: [10, 4]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [10, 5]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [10, 6]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [10, 7]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [10, 8]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [10, 9]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [10, 10]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [10, 11]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [10, 12]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td></tr><tr><td title=\"Index: [11, 0]&#10;Color: (144, 120, 70)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 120, 70);\"></td><td title=\"Index: [11, 1]&#10;Color: (144, 120, 70)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 120, 70);\"></td><td title=\"Index: [11, 2]&#10;Color: (144, 120, 70)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 120, 70);\"></td><td title=\"Index: [11, 3]&#10;Color: (144, 120, 70)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 120, 70);\"></td><td title=\"Index: [11, 4]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [11, 5]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [11, 6]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [11, 7]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [11, 8]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [11, 9]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [11, 10]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [11, 11]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [11, 12]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td></tr><tr><td title=\"Index: [12, 0]&#10;Color: (144, 120, 70)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 120, 70);\"></td><td title=\"Index: [12, 1]&#10;Color: (144, 120, 70)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 120, 70);\"></td><td title=\"Index: [12, 2]&#10;Color: (144, 120, 70)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 120, 70);\"></td><td title=\"Index: [12, 3]&#10;Color: (144, 120, 70)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 120, 70);\"></td><td title=\"Index: [12, 4]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [12, 5]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [12, 6]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [12, 7]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [12, 8]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [12, 9]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [12, 10]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [12, 11]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td><td title=\"Index: [12, 12]&#10;Color: (72, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(72, 24, 170);\"></td></tr></tbody></table>"
       ],
       "metadata": {},
       "output_type": "display_data",
       "text": [
        "<IPython.core.display.HTML at 0x10bc60ed0>"
       ]
      },
      {
       "html": [
        "<style type=\"text/css\">table.blockgrid {border: none;} .blockgrid tr {border: none;} .blockgrid td {padding: 0px;} #blocksaf405d16-d16c-460b-8044-37c807a5c077 td {border: 1px solid white;}</style><table id=\"blocksaf405d16-d16c-460b-8044-37c807a5c077\" class=\"blockgrid\"><tbody><tr><td title=\"Index: [0, 0]&#10;Color: (168, 24, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 24, 240);\"></td><td title=\"Index: [0, 1]&#10;Color: (168, 24, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 24, 240);\"></td><td title=\"Index: [0, 2]&#10;Color: (168, 24, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 24, 240);\"></td><td title=\"Index: [0, 3]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [0, 4]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [0, 5]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [0, 6]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [0, 7]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [0, 8]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [0, 9]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [0, 10]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td></tr><tr><td title=\"Index: [1, 0]&#10;Color: (168, 24, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 24, 240);\"></td><td title=\"Index: [1, 1]&#10;Color: (168, 24, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 24, 240);\"></td><td title=\"Index: [1, 2]&#10;Color: (168, 24, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 24, 240);\"></td><td title=\"Index: [1, 3]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [1, 4]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [1, 5]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [1, 6]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [1, 7]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [1, 8]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [1, 9]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [1, 10]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td></tr><tr><td title=\"Index: [2, 0]&#10;Color: (168, 24, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 24, 240);\"></td><td title=\"Index: [2, 1]&#10;Color: (168, 24, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 24, 240);\"></td><td title=\"Index: [2, 2]&#10;Color: (168, 24, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 24, 240);\"></td><td title=\"Index: [2, 3]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [2, 4]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [2, 5]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [2, 6]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [2, 7]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [2, 8]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [2, 9]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [2, 10]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td></tr><tr><td title=\"Index: [3, 0]&#10;Color: (168, 24, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 24, 240);\"></td><td title=\"Index: [3, 1]&#10;Color: (168, 24, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 24, 240);\"></td><td title=\"Index: [3, 2]&#10;Color: (168, 24, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 24, 240);\"></td><td title=\"Index: [3, 3]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [3, 4]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [3, 5]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [3, 6]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [3, 7]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [3, 8]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [3, 9]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [3, 10]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td></tr><tr><td title=\"Index: [4, 0]&#10;Color: (168, 24, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 24, 240);\"></td><td title=\"Index: [4, 1]&#10;Color: (168, 24, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 24, 240);\"></td><td title=\"Index: [4, 2]&#10;Color: (168, 24, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 24, 240);\"></td><td title=\"Index: [4, 3]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [4, 4]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [4, 5]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [4, 6]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [4, 7]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [4, 8]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [4, 9]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td><td title=\"Index: [4, 10]&#10;Color: (120, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 48, 0);\"></td></tr><tr><td title=\"Index: [5, 0]&#10;Color: (168, 24, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 24, 240);\"></td><td title=\"Index: [5, 1]&#10;Color: (168, 24, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 24, 240);\"></td><td title=\"Index: [5, 2]&#10;Color: (168, 24, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 24, 240);\"></td><td title=\"Index: [5, 3]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [5, 4]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [5, 5]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [5, 6]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [5, 7]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [5, 8]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [5, 9]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [5, 10]&#10;Color: (216, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(216, 96, 170);\"></td></tr><tr><td title=\"Index: [6, 0]&#10;Color: (168, 24, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 24, 240);\"></td><td title=\"Index: [6, 1]&#10;Color: (168, 24, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 24, 240);\"></td><td title=\"Index: [6, 2]&#10;Color: (168, 24, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 24, 240);\"></td><td title=\"Index: [6, 3]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [6, 4]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [6, 5]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [6, 6]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [6, 7]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [6, 8]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [6, 9]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [6, 10]&#10;Color: (216, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(216, 96, 170);\"></td></tr><tr><td title=\"Index: [7, 0]&#10;Color: (168, 24, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 24, 240);\"></td><td title=\"Index: [7, 1]&#10;Color: (168, 24, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 24, 240);\"></td><td title=\"Index: [7, 2]&#10;Color: (168, 24, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 24, 240);\"></td><td title=\"Index: [7, 3]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [7, 4]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [7, 5]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [7, 6]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [7, 7]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [7, 8]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [7, 9]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [7, 10]&#10;Color: (216, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(216, 96, 170);\"></td></tr><tr><td title=\"Index: [8, 0]&#10;Color: (168, 24, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 24, 240);\"></td><td title=\"Index: [8, 1]&#10;Color: (168, 24, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 24, 240);\"></td><td title=\"Index: [8, 2]&#10;Color: (168, 24, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 24, 240);\"></td><td title=\"Index: [8, 3]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [8, 4]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [8, 5]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [8, 6]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [8, 7]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [8, 8]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [8, 9]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [8, 10]&#10;Color: (216, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(216, 96, 170);\"></td></tr><tr><td title=\"Index: [9, 0]&#10;Color: (192, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 0, 50);\"></td><td title=\"Index: [9, 1]&#10;Color: (192, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 0, 50);\"></td><td title=\"Index: [9, 2]&#10;Color: (192, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 0, 50);\"></td><td title=\"Index: [9, 3]&#10;Color: (192, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 0, 50);\"></td><td title=\"Index: [9, 4]&#10;Color: (192, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 0, 50);\"></td><td title=\"Index: [9, 5]&#10;Color: (192, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 0, 50);\"></td><td title=\"Index: [9, 6]&#10;Color: (192, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 0, 50);\"></td><td title=\"Index: [9, 7]&#10;Color: (192, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 0, 50);\"></td><td title=\"Index: [9, 8]&#10;Color: (192, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 0, 50);\"></td><td title=\"Index: [9, 9]&#10;Color: (192, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 0, 50);\"></td><td title=\"Index: [9, 10]&#10;Color: (216, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(216, 96, 170);\"></td></tr><tr><td title=\"Index: [10, 0]&#10;Color: (192, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 0, 50);\"></td><td title=\"Index: [10, 1]&#10;Color: (192, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 0, 50);\"></td><td title=\"Index: [10, 2]&#10;Color: (192, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 0, 50);\"></td><td title=\"Index: [10, 3]&#10;Color: (192, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 0, 50);\"></td><td title=\"Index: [10, 4]&#10;Color: (192, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 0, 50);\"></td><td title=\"Index: [10, 5]&#10;Color: (192, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 0, 50);\"></td><td title=\"Index: [10, 6]&#10;Color: (192, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 0, 50);\"></td><td title=\"Index: [10, 7]&#10;Color: (192, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 0, 50);\"></td><td title=\"Index: [10, 8]&#10;Color: (192, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 0, 50);\"></td><td title=\"Index: [10, 9]&#10;Color: (192, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 0, 50);\"></td><td title=\"Index: [10, 10]&#10;Color: (216, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(216, 96, 170);\"></td></tr></tbody></table>"
       ],
       "metadata": {},
       "output_type": "display_data",
       "text": [
        "<IPython.core.display.HTML at 0x10bc75e90>"
       ]
      },
      {
       "html": [
        "<style type=\"text/css\">table.blockgrid {border: none;} .blockgrid tr {border: none;} .blockgrid td {padding: 0px;} #blocks5bb52b67-bb69-47fb-a77b-61c8cc5ce472 td {border: 1px solid white;}</style><table id=\"blocks5bb52b67-bb69-47fb-a77b-61c8cc5ce472\" class=\"blockgrid\"><tbody><tr><td title=\"Index: [0, 0]&#10;Color: (192, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 48, 0);\"></td><td title=\"Index: [0, 1]&#10;Color: (192, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 48, 0);\"></td><td title=\"Index: [0, 2]&#10;Color: (216, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(216, 24, 170);\"></td><td title=\"Index: [0, 3]&#10;Color: (216, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(216, 24, 170);\"></td><td title=\"Index: [0, 4]&#10;Color: (216, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(216, 24, 170);\"></td><td title=\"Index: [0, 5]&#10;Color: (216, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(216, 24, 170);\"></td><td title=\"Index: [0, 6]&#10;Color: (216, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(216, 24, 170);\"></td><td title=\"Index: [0, 7]&#10;Color: (216, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(216, 24, 170);\"></td><td title=\"Index: [0, 8]&#10;Color: (216, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(216, 24, 170);\"></td><td title=\"Index: [0, 9]&#10;Color: (216, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(216, 24, 170);\"></td><td title=\"Index: [0, 10]&#10;Color: (216, 24, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(216, 24, 170);\"></td></tr><tr><td title=\"Index: [1, 0]&#10;Color: (192, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 48, 0);\"></td><td title=\"Index: [1, 1]&#10;Color: (192, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 48, 0);\"></td><td title=\"Index: [1, 2]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [1, 3]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [1, 4]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [1, 5]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [1, 6]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [1, 7]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [1, 8]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [1, 9]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [1, 10]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td></tr><tr><td title=\"Index: [2, 0]&#10;Color: (192, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 48, 0);\"></td><td title=\"Index: [2, 1]&#10;Color: (192, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 48, 0);\"></td><td title=\"Index: [2, 2]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [2, 3]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [2, 4]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [2, 5]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [2, 6]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [2, 7]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [2, 8]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [2, 9]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [2, 10]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td></tr><tr><td title=\"Index: [3, 0]&#10;Color: (192, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 48, 0);\"></td><td title=\"Index: [3, 1]&#10;Color: (192, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 48, 0);\"></td><td title=\"Index: [3, 2]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [3, 3]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [3, 4]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [3, 5]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [3, 6]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [3, 7]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [3, 8]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [3, 9]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [3, 10]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td></tr><tr><td title=\"Index: [4, 0]&#10;Color: (192, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 48, 0);\"></td><td title=\"Index: [4, 1]&#10;Color: (192, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 48, 0);\"></td><td title=\"Index: [4, 2]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [4, 3]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [4, 4]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [4, 5]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [4, 6]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [4, 7]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [4, 8]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [4, 9]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [4, 10]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td></tr><tr><td title=\"Index: [5, 0]&#10;Color: (192, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 48, 0);\"></td><td title=\"Index: [5, 1]&#10;Color: (192, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 48, 0);\"></td><td title=\"Index: [5, 2]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [5, 3]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [5, 4]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [5, 5]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [5, 6]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [5, 7]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [5, 8]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [5, 9]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [5, 10]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td></tr><tr><td title=\"Index: [6, 0]&#10;Color: (192, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 48, 0);\"></td><td title=\"Index: [6, 1]&#10;Color: (192, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 48, 0);\"></td><td title=\"Index: [6, 2]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [6, 3]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [6, 4]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [6, 5]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [6, 6]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [6, 7]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [6, 8]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [6, 9]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [6, 10]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td></tr><tr><td title=\"Index: [7, 0]&#10;Color: (192, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 48, 0);\"></td><td title=\"Index: [7, 1]&#10;Color: (192, 48, 0)\" style=\"width: 20px; height: 20px;background-color: rgb(192, 48, 0);\"></td><td title=\"Index: [7, 2]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [7, 3]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [7, 4]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [7, 5]&#10;Color: (144, 72, 120)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 72, 120);\"></td><td title=\"Index: [7, 6]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [7, 7]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [7, 8]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [7, 9]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [7, 10]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td></tr><tr><td title=\"Index: [8, 0]&#10;Color: (168, 96, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 96, 240);\"></td><td title=\"Index: [8, 1]&#10;Color: (168, 96, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 96, 240);\"></td><td title=\"Index: [8, 2]&#10;Color: (168, 96, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 96, 240);\"></td><td title=\"Index: [8, 3]&#10;Color: (168, 96, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 96, 240);\"></td><td title=\"Index: [8, 4]&#10;Color: (168, 96, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 96, 240);\"></td><td title=\"Index: [8, 5]&#10;Color: (168, 96, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 96, 240);\"></td><td title=\"Index: [8, 6]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [8, 7]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [8, 8]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [8, 9]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [8, 10]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td></tr><tr><td title=\"Index: [9, 0]&#10;Color: (168, 96, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 96, 240);\"></td><td title=\"Index: [9, 1]&#10;Color: (168, 96, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 96, 240);\"></td><td title=\"Index: [9, 2]&#10;Color: (168, 96, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 96, 240);\"></td><td title=\"Index: [9, 3]&#10;Color: (168, 96, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 96, 240);\"></td><td title=\"Index: [9, 4]&#10;Color: (168, 96, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 96, 240);\"></td><td title=\"Index: [9, 5]&#10;Color: (168, 96, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 96, 240);\"></td><td title=\"Index: [9, 6]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [9, 7]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [9, 8]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [9, 9]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [9, 10]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td></tr><tr><td title=\"Index: [10, 0]&#10;Color: (168, 96, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 96, 240);\"></td><td title=\"Index: [10, 1]&#10;Color: (168, 96, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 96, 240);\"></td><td title=\"Index: [10, 2]&#10;Color: (168, 96, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 96, 240);\"></td><td title=\"Index: [10, 3]&#10;Color: (168, 96, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 96, 240);\"></td><td title=\"Index: [10, 4]&#10;Color: (168, 96, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 96, 240);\"></td><td title=\"Index: [10, 5]&#10;Color: (168, 96, 240)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 96, 240);\"></td><td title=\"Index: [10, 6]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [10, 7]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [10, 8]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [10, 9]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [10, 10]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td></tr></tbody></table>"
       ],
       "metadata": {},
       "output_type": "display_data",
       "text": [
        "<IPython.core.display.HTML at 0x10bc75290>"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "CPU times: user 488 ms, sys: 21.5 ms, total: 510 ms\n",
        "Wall time: 495 ms\n"
       ]
      }
     ],
     "prompt_number": 126
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "We see it takes about half a second to go through all 945 sets of rectangles, find the 35 sets whose total area is a perfect square, try to pack each set into a square, and display the four that work. (I had a couple of ideas for how to make this faster, but I won't bother because it is plenty fast enough.)"
     ]
    },
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Animated Colored Rectangles"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "It is gratifying to see the final results, and have the computation be so fast, but I'd like to get a better understanding of the process of finding the results.  I can try to visualize the process by *animating* the search that `pack` does: every time we consider placing a new rectangle, show the grid, and then pause for a short period.  If you are running this in a live IPython notebook (not in nbviewer), you can see for yourself by running this cell:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import IPython.display \n",
      "import time\n",
      "\n",
      "def pack(rectangles, grid):\n",
      "    \"\"\"Find a way to pack all rectangles onto grid and return the packed grid,\n",
      "    or return None if not possible.\"\"\"\n",
      "    if not rectangles:\n",
      "        return grid # Placing no rectangles give you the original grid\n",
      "    elif not grid:\n",
      "        return None  # Can't put rectangles on an illegal grid\n",
      "    else:\n",
      "        show(grid)                     # <<<<<<<<<<<<<<<< CHANGE HERE\n",
      "        time.sleep(0.3)                # <<<<<<<<<<<<<<<< CHANGE HERE\n",
      "        IPython.display.clear_output() # <<<<<<<<<<<<<<<< CHANGE HERE        \n",
      "        pos = first_empty_cell(grid)\n",
      "        for (w, h) in rectangles: # for each rectangle\n",
      "            for rect in [(w, h), (h, w)]: # in each orientation\n",
      "                grid2 = place_rectangle_at(rect, grid, pos)\n",
      "                solution = pack(rectangles - {(w, h)}, grid2)\n",
      "                if solution:\n",
      "                    return solution\n",
      "        return None\n",
      "\n",
      "rectangles = {(1, 2), (3, 7), (4, 6), (5, 10), (8, 9)}\n",
      "show_packable([rectangles])"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "html": [
        "<style type=\"text/css\">table.blockgrid {border: none;} .blockgrid tr {border: none;} .blockgrid td {padding: 0px;} #blocks7045f437-0837-4fa3-819c-0f15945b7068 td {border: 1px solid white;}</style><table id=\"blocks7045f437-0837-4fa3-819c-0f15945b7068\" class=\"blockgrid\"><tbody><tr><td title=\"Index: [0, 0]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [0, 1]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [0, 2]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [0, 3]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [0, 4]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [0, 5]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [0, 6]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [0, 7]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [0, 8]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [0, 9]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [0, 10]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [0, 11]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [0, 12]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td></tr><tr><td title=\"Index: [1, 0]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [1, 1]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [1, 2]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [1, 3]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [1, 4]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [1, 5]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [1, 6]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [1, 7]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [1, 8]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [1, 9]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [1, 10]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [1, 11]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [1, 12]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td></tr><tr><td title=\"Index: [2, 0]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [2, 1]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [2, 2]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [2, 3]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [2, 4]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [2, 5]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [2, 6]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [2, 7]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [2, 8]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [2, 9]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [2, 10]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [2, 11]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [2, 12]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td></tr><tr><td title=\"Index: [3, 0]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [3, 1]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [3, 2]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [3, 3]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [3, 4]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [3, 5]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [3, 6]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [3, 7]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [3, 8]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [3, 9]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [3, 10]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [3, 11]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [3, 12]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td></tr><tr><td title=\"Index: [4, 0]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [4, 1]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [4, 2]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [4, 3]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [4, 4]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [4, 5]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [4, 6]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [4, 7]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [4, 8]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [4, 9]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [4, 10]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [4, 11]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [4, 12]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td></tr><tr><td title=\"Index: [5, 0]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [5, 1]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [5, 2]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [5, 3]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [5, 4]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [5, 5]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [5, 6]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [5, 7]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [5, 8]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [5, 9]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [5, 10]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [5, 11]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [5, 12]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td></tr><tr><td title=\"Index: [6, 0]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [6, 1]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [6, 2]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [6, 3]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [6, 4]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [6, 5]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [6, 6]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [6, 7]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [6, 8]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [6, 9]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [6, 10]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [6, 11]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [6, 12]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td></tr><tr><td title=\"Index: [7, 0]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [7, 1]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [7, 2]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [7, 3]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [7, 4]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [7, 5]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [7, 6]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [7, 7]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [7, 8]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [7, 9]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [7, 10]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [7, 11]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [7, 12]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td></tr><tr><td title=\"Index: [8, 0]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [8, 1]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [8, 2]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [8, 3]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [8, 4]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [8, 5]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [8, 6]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [8, 7]&#10;Color: (48, 24, 100)\" style=\"width: 20px; height: 20px;background-color: rgb(48, 24, 100);\"></td><td title=\"Index: [8, 8]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [8, 9]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [8, 10]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [8, 11]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [8, 12]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td></tr><tr><td title=\"Index: [9, 0]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [9, 1]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [9, 2]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [9, 3]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [9, 4]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [9, 5]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [9, 6]&#10;Color: (216, 192, 70)\" style=\"width: 20px; height: 20px;background-color: rgb(216, 192, 70);\"></td><td title=\"Index: [9, 7]&#10;Color: (216, 192, 70)\" style=\"width: 20px; height: 20px;background-color: rgb(216, 192, 70);\"></td><td title=\"Index: [9, 8]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [9, 9]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [9, 10]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [9, 11]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td><td title=\"Index: [9, 12]&#10;Color: (120, 0, 50)\" style=\"width: 20px; height: 20px;background-color: rgb(120, 0, 50);\"></td></tr><tr><td title=\"Index: [10, 0]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [10, 1]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [10, 2]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [10, 3]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [10, 4]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [10, 5]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [10, 6]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [10, 7]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [10, 8]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [10, 9]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [10, 10]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [10, 11]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [10, 12]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td></tr><tr><td title=\"Index: [11, 0]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [11, 1]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [11, 2]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [11, 3]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [11, 4]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [11, 5]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [11, 6]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [11, 7]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [11, 8]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [11, 9]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [11, 10]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [11, 11]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [11, 12]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td></tr><tr><td title=\"Index: [12, 0]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [12, 1]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [12, 2]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [12, 3]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [12, 4]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [12, 5]&#10;Color: (144, 96, 170)\" style=\"width: 20px; height: 20px;background-color: rgb(144, 96, 170);\"></td><td title=\"Index: [12, 6]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [12, 7]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [12, 8]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [12, 9]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [12, 10]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [12, 11]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td><td title=\"Index: [12, 12]&#10;Color: (168, 72, 190)\" style=\"width: 20px; height: 20px;background-color: rgb(168, 72, 190);\"></td></tr></tbody></table>"
       ],
       "metadata": {},
       "output_type": "display_data",
       "text": [
        "<IPython.core.display.HTML at 0x10abec350>"
       ]
      }
     ],
     "prompt_number": 127
    },
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "And Now For Something Completely Different"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "On April 28, Gary Antonik had another [Numberplay column](http://wordplay.blogs.nytimes.com/2014/04/14/rectangle) that quotes my friend Bill Gosper. (Gosper often presents more advanced puzzles in the [math-fun](http://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun) mailing list.)  This puzzle was:\n",
      "\n",
      ">For the expression  N U M + B E R = P L A Y,\n",
      "\n",
      "> Which distinct numerals (each different) can be substituted for letters to make a valid expression?\n",
      "\n",
      "> How many solutions are there?"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "I tackled this type of problem (known as a [cryptarithmetic](http://mathworld.wolfram.com/Cryptarithmetic.html) or [alphametic](http://mathworld.wolfram.com/Alphametic.html) problem) in my Udacity class [CS 212](https://www.udacity.com/wiki/cs212/unit-2#cryptarithmetic). My approach was simple: try all permutations of digits replacing letters (that should be quick and easy&mdash;there can be at most 10 factorial or 3.6 million permutations), then for each one, use Python's `eval` function to see if the resulting string is a true expression.  The basic idea is simple, but there are complications to worry about:\n",
      "\n",
      "1. Math uses `=` and Python uses `==` for equality; we'll allow either one.\n",
      "2. The more detailed rules for these problems say that a number with a leading zero (like `012`) is illegal (but `0` itself is ok).\n",
      "3. By default, Python thinks that 3/2 is 1, because integer division rounds down.  But we can import \"proper\" division from the future.\n",
      "4. If we try to eval an expression like 1/0, Python raises an error; we'll have to handle it."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import itertools, string, re\n",
      "\n",
      "def solve_all(formula):\n",
      "    \"\"\"Given a formula like 'NUM + BER = PLAY', fill in digits to solve it.\n",
      "    Input formula is a string; generate each digit-filled-in string.\"\"\"\n",
      "    for exp in replace_letters(formula.replace(' = ', ' == ')):\n",
      "        if valid(exp):\n",
      "            yield exp\n",
      "\n",
      "def replace_letters(formula):\n",
      "    \"Generate all possible replacements of letters with digits in formula.\"\n",
      "    letters = ''.join(set(re.findall('[A-Z]', formula)))\n",
      "    for digits in itertools.permutations('1234567890', len(letters)):\n",
      "        trans = string.maketrans(letters, ''.join(digits))\n",
      "        yield formula.translate(trans)\n",
      "\n",
      "def valid(exp):\n",
      "    \"Expression is valid iff it has no numbers with leading zero, and evals true.\"\n",
      "    try:\n",
      "        return not re.search(r'\\b0[0-9]', exp) and (eval(exp) is True)\n",
      "    except ArithmeticError:\n",
      "        return False"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 137
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "% time list(solve_all('NUM + BER = PLAY'))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "CPU times: user 50.8 s, sys: 1.77 s, total: 52.6 s\n",
        "Wall time: 51.5 s\n"
       ]
      },
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 141,
       "text": [
        "['587 + 439 == 1026',\n",
        " '589 + 437 == 1026',\n",
        " '537 + 489 == 1026',\n",
        " '539 + 487 == 1026',\n",
        " '487 + 539 == 1026',\n",
        " '489 + 537 == 1026',\n",
        " '437 + 589 == 1026',\n",
        " '439 + 587 == 1026',\n",
        " '786 + 249 == 1035',\n",
        " '789 + 246 == 1035',\n",
        " '746 + 289 == 1035',\n",
        " '749 + 286 == 1035',\n",
        " '286 + 749 == 1035',\n",
        " '289 + 746 == 1035',\n",
        " '246 + 789 == 1035',\n",
        " '249 + 786 == 1035',\n",
        " '784 + 269 == 1053',\n",
        " '789 + 264 == 1053',\n",
        " '764 + 289 == 1053',\n",
        " '769 + 284 == 1053',\n",
        " '284 + 769 == 1053',\n",
        " '289 + 764 == 1053',\n",
        " '264 + 789 == 1053',\n",
        " '269 + 784 == 1053',\n",
        " '583 + 479 == 1062',\n",
        " '589 + 473 == 1062',\n",
        " '573 + 489 == 1062',\n",
        " '579 + 483 == 1062',\n",
        " '483 + 579 == 1062',\n",
        " '489 + 573 == 1062',\n",
        " '473 + 589 == 1062',\n",
        " '479 + 583 == 1062',\n",
        " '764 + 325 == 1089',\n",
        " '765 + 324 == 1089',\n",
        " '724 + 365 == 1089',\n",
        " '725 + 364 == 1089',\n",
        " '652 + 437 == 1089',\n",
        " '657 + 432 == 1089',\n",
        " '632 + 457 == 1089',\n",
        " '637 + 452 == 1089',\n",
        " '452 + 637 == 1089',\n",
        " '457 + 632 == 1089',\n",
        " '432 + 657 == 1089',\n",
        " '437 + 652 == 1089',\n",
        " '364 + 725 == 1089',\n",
        " '365 + 724 == 1089',\n",
        " '324 + 765 == 1089',\n",
        " '325 + 764 == 1089',\n",
        " '752 + 346 == 1098',\n",
        " '756 + 342 == 1098',\n",
        " '742 + 356 == 1098',\n",
        " '746 + 352 == 1098',\n",
        " '673 + 425 == 1098',\n",
        " '675 + 423 == 1098',\n",
        " '623 + 475 == 1098',\n",
        " '625 + 473 == 1098',\n",
        " '473 + 625 == 1098',\n",
        " '475 + 623 == 1098',\n",
        " '423 + 675 == 1098',\n",
        " '425 + 673 == 1098',\n",
        " '352 + 746 == 1098',\n",
        " '356 + 742 == 1098',\n",
        " '342 + 756 == 1098',\n",
        " '346 + 752 == 1098',\n",
        " '857 + 349 == 1206',\n",
        " '859 + 347 == 1206',\n",
        " '847 + 359 == 1206',\n",
        " '849 + 357 == 1206',\n",
        " '876 + 429 == 1305',\n",
        " '879 + 426 == 1305',\n",
        " '826 + 479 == 1305',\n",
        " '829 + 476 == 1305',\n",
        " '874 + 629 == 1503',\n",
        " '879 + 624 == 1503',\n",
        " '824 + 679 == 1503',\n",
        " '829 + 674 == 1503',\n",
        " '853 + 749 == 1602',\n",
        " '859 + 743 == 1602',\n",
        " '843 + 759 == 1602',\n",
        " '849 + 753 == 1602',\n",
        " '674 + 829 == 1503',\n",
        " '476 + 829 == 1305',\n",
        " '479 + 826 == 1305',\n",
        " '679 + 824 == 1503',\n",
        " '753 + 849 == 1602',\n",
        " '357 + 849 == 1206',\n",
        " '359 + 847 == 1206',\n",
        " '759 + 843 == 1602',\n",
        " '743 + 859 == 1602',\n",
        " '347 + 859 == 1206',\n",
        " '349 + 857 == 1206',\n",
        " '749 + 853 == 1602',\n",
        " '624 + 879 == 1503',\n",
        " '426 + 879 == 1305',\n",
        " '429 + 876 == 1305',\n",
        " '629 + 874 == 1503']"
       ]
      }
     ],
     "prompt_number": 141
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "len(_)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 143,
       "text": [
        "96"
       ]
      }
     ],
     "prompt_number": 143
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "So there are 96 solutions, and we can see each one. It is a little disapointing that it takes about a minute to solve.  In my Udacity class I show another approach that is about 20 times faster; you can [go there](https://www.udacity.com/wiki/cs212/unit-2#rethinking-eval) to see it."
     ]
    }
   ],
   "metadata": {}
  }
 ]
}