Added blurb and trusted notebooks
authorNeil Smith <neil.git@njae.me.uk>
Wed, 8 Mar 2017 14:09:13 +0000 (06:09 -0800)
committerNeil Smith <neil.git@njae.me.uk>
Wed, 8 Mar 2017 14:09:13 +0000 (06:09 -0800)
monotone-substrings/generate_sequence.ipynb
monotone-substrings/single_substring.ipynb
monotone-substrings/single_substring_itertools.ipynb
wordsearch/wordsearch-creation.ipynb
wordsearch/wordsearch-solving.ipynb

index 275fa884252bd80a5032606a0aa5c33ae04e41d4..83b8907790433afa6d628c924d12faedfe84251d 100644 (file)
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
-   "version": "3.5.2+"
+   "version": "3.5.2"
   }
  },
  "nbformat": 4,
index 9fb72850f45faa4e540b95173ddbe7c3b12f05b4..c800ab91a5c74b0a8ef48c6fc12230b3e2d3431d 100644 (file)
@@ -1,5 +1,33 @@
 {
  "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Monotone substrings\n",
+    "\n",
+    "Given a list of numbers, find the length of longest increasing or decreasing substring in the list.\n",
+    "\n",
+    "For instance, the sequence\n",
+    "  10, 1, 2, 3, 4, 5, 5, 5, 6, 4, 3, 5, 6\n",
+    "contains these increasing or decreasing substrings:\n",
+    "* 10, 1\n",
+    "* 1, 2, 3, 4, 5\n",
+    "* 5, 6\n",
+    "* 6, 4, 3\n",
+    "* 3, 5, 6\n",
+    "\n",
+    "As an extension, allow the substring to contain runs of identical numbers, each of which is included in the length of the longest substring.\n",
+    "\n",
+    "If identical numbers are allowed, the above sequence contains substrings:\n",
+    "* 10, 1\n",
+    "* 1, 2, 3, 4, 5, 5, 5, 6\n",
+    "* 6, 4, 3\n",
+    "* 3, 5, 6\n",
+    "\n",
+    "The list is given as a single line of comma-separated integers. "
+   ]
+  },
   {
    "cell_type": "code",
    "execution_count": 1,
   },
   {
    "cell_type": "code",
-   "execution_count": 4,
+   "execution_count": 8,
    "metadata": {
     "collapsed": false
    },
        "5"
       ]
      },
-     "execution_count": 4,
+     "execution_count": 8,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 5,
+   "execution_count": 9,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "   2 False\t10\t>\t1\n",
+      "   2 True\t1\t<\t2\n",
+      "   3 True\t2\t<\t3\n",
+      "   4 True\t3\t<\t4\n",
+      "   5 True\t4\t<\t5\n",
+      "   1 True\t5\t=\t5\n",
+      "   1 True\t5\t=\t5\n",
+      "   2 True\t5\t<\t6\n",
+      "   2 False\t6\t>\t4\n",
+      "   3 False\t4\t>\t3\n",
+      "   2 True\t3\t<\t5\n",
+      "   3 True\t5\t<\t6\n"
+     ]
+    },
+    {
+     "data": {
+      "text/plain": [
+       "5"
+      ]
+     },
+     "execution_count": 9,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "longest_monotone([10,1,2,3,4,5,5,5,6,4,3,5,6], debug=True)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 7,
    "metadata": {
     "collapsed": false
    },
       "   5 True\t4\t<\t5\n",
       "   6 True\t5\t=\t5\n",
       "   7 True\t5\t=\t5\n",
-      "   4 False\t5\t>\t4\n",
-      "   5 False\t4\t>\t3\n",
+      "   8 True\t5\t<\t6\n",
+      "   2 False\t6\t>\t4\n",
+      "   3 False\t4\t>\t3\n",
       "   2 True\t3\t<\t5\n",
       "   3 True\t5\t<\t6\n"
      ]
     {
      "data": {
       "text/plain": [
-       "7"
+       "8"
       ]
      },
-     "execution_count": 5,
+     "execution_count": 7,
      "metadata": {},
      "output_type": "execute_result"
     }
    ],
    "source": [
-    "longest_monotone([10,1,2,3,4,5,5,5,4,3,5,6], allow_same=True, debug=True)"
+    "longest_monotone([10,1,2,3,4,5,5,5,6,4,3,5,6], allow_same=True, debug=True)"
    ]
   },
   {
index 80c2d2ac016fa2a4acaa5e97bbf8be379f41ede2..1e0f20d00e3e8969b72f5a9056481f3801797e2a 100644 (file)
@@ -1,5 +1,33 @@
 {
  "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Monotone substrings\n",
+    "\n",
+    "Given a list of numbers, find the length of longest increasing or decreasing substring in the list.\n",
+    "\n",
+    "For instance, the sequence\n",
+    "  10, 1, 2, 3, 4, 5, 5, 5, 6, 4, 3, 5, 6\n",
+    "contains these increasing or decreasing substrings:\n",
+    "* 10, 1\n",
+    "* 1, 2, 3, 4, 5\n",
+    "* 5, 6\n",
+    "* 6, 4, 3\n",
+    "* 3, 5, 6\n",
+    "\n",
+    "As an extension, allow the substring to contain runs of identical numbers, each of which is included in the length of the longest substring.\n",
+    "\n",
+    "If identical numbers are allowed, the above sequence contains substrings:\n",
+    "* 10, 1\n",
+    "* 1, 2, 3, 4, 5, 5, 5, 6\n",
+    "* 6, 4, 3\n",
+    "* 3, 5, 6\n",
+    "\n",
+    "The list is given as a single line of comma-separated integers. "
+   ]
+  },
   {
    "cell_type": "code",
    "execution_count": 1,
index 4a70378e75b18d46cd20917c299d5500bd1e762e..8a81e740d1d85a109a7a6dd6ad45c2c4cf548056 100644 (file)
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
-   "version": "3.5.2+"
+   "version": "3.5.2"
   }
  },
  "nbformat": 4,
index 89b8637ce637fccf631e10e0290635aa4b1dec40..b2c6c7ed6f748dc9ea3b452a4e9ec89a742f5f7f 100644 (file)
@@ -1,5 +1,24 @@
 {
  "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Wordsearch\n",
+    "Given a text file, consisting of three parts (a grid size, a grid, and a list of words), find:\n",
+    "* the words present in the grid, \n",
+    "* the longest word present in the grid, \n",
+    "* the number of words not present in the grid, \n",
+    "* the longest word not present that can be formed from the leftover letters\n",
+    "\n",
+    "The only words that need be considered are the ones given in the list in the puzzle input.\n",
+    "\n",
+    "The puzzle consists of:\n",
+    "1. A line consisting of _w_`x`_h_, where _w_ and _h_ are integers giving the width and height of the grid.\n",
+    "2. The grid itself, consisting of _h_ lines each of _w_ letters.\n",
+    "3. A list of words, one word per line, of arbitrary length. "
+   ]
+  },
   {
    "cell_type": "code",
    "execution_count": 13,
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
-   "version": "3.5.2+"
+   "version": "3.5.2"
   }
  },
  "nbformat": 4,