--- /dev/null
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Given a sequence of {F|L|R}, each of which is \"move forward one step\", \"turn left, then move forward one step\", \"turn right, then move forward one step\":\n",
+ "1. which tours are closed?\n",
+ "2. what is the area enclosed by the tour?"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "import collections\n",
+ "import enum\n",
+ "import random\n",
+ "import os\n",
+ "\n",
+ "import matplotlib.pyplot as plt\n",
+ "%matplotlib inline\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "class Direction(enum.Enum):\n",
+ " UP = 1\n",
+ " RIGHT = 2\n",
+ " DOWN = 3\n",
+ " LEFT = 4\n",
+ " \n",
+ "turn_lefts = {Direction.UP: Direction.LEFT, Direction.LEFT: Direction.DOWN,\n",
+ " Direction.DOWN: Direction.RIGHT, Direction.RIGHT: Direction.UP}\n",
+ "\n",
+ "turn_rights = {Direction.UP: Direction.RIGHT, Direction.RIGHT: Direction.DOWN,\n",
+ " Direction.DOWN: Direction.LEFT, Direction.LEFT: Direction.UP}\n",
+ "\n",
+ "def turn_left(d):\n",
+ " return turn_lefts[d]\n",
+ "\n",
+ "def turn_right(d):\n",
+ " return turn_rights[d]\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "Step = collections.namedtuple('Step', ['x', 'y', 'dir'])\n",
+ "Mistake = collections.namedtuple('Mistake', ['i', 'step'])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "def advance(step, d):\n",
+ " if d == Direction.UP:\n",
+ " return Step(step.x, step.y+1, d)\n",
+ " elif d == Direction.DOWN:\n",
+ " return Step(step.x, step.y-1, d)\n",
+ " elif d == Direction.LEFT:\n",
+ " return Step(step.x-1, step.y, d)\n",
+ " elif d == Direction.RIGHT:\n",
+ " return Step(step.x+1, step.y, d)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "def step(s, current):\n",
+ " if s == 'F':\n",
+ " return advance(current, current.dir)\n",
+ " elif s == 'L':\n",
+ " return advance(current, turn_left(current.dir))\n",
+ " elif s == 'R':\n",
+ " return advance(current, turn_right(current.dir))\n",
+ " else:\n",
+ " raise ValueError"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "def trace_tour(tour, startx=0, starty=0, startdir=Direction.RIGHT):\n",
+ " current = Step(startx, starty, startdir)\n",
+ " trace = [current]\n",
+ " for s in tour:\n",
+ " current = step(s, current)\n",
+ " trace += [current]\n",
+ " return trace "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "def positions(trace):\n",
+ " return [(s.x, s.y) for s in trace]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "def valid(trace):\n",
+ " return (trace[-1].x == 0 \n",
+ " and trace[-1].y == 0 \n",
+ " and len(set(positions(trace))) + 1 == len(trace))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "def valid_prefix(tour):\n",
+ " current = Step(0, 0, Direction.RIGHT)\n",
+ " prefix = []\n",
+ " posns = []\n",
+ " for s in tour:\n",
+ " current = step(s, current)\n",
+ " prefix += [s]\n",
+ " if (current.x, current.y) in posns:\n",
+ " return ''\n",
+ " elif current.x == 0 and current.y == 0: \n",
+ " return ''.join(prefix)\n",
+ " posns += [(current.x, current.y)]\n",
+ " if current.x == 0 and current.y == 0:\n",
+ " return ''.join(prefix)\n",
+ " else:\n",
+ " return ''"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "def mistake_positions(trace, debug=False):\n",
+ " mistakes = []\n",
+ " current = trace[0]\n",
+ " posns = [(0, 0)]\n",
+ " for i, current in enumerate(trace[1:]):\n",
+ " if (current.x, current.y) in posns:\n",
+ " if debug: print(i, current)\n",
+ " mistakes += [Mistake(i+1, current)]\n",
+ " posns += [(current.x, current.y)]\n",
+ " if (current.x, current.y) == (0, 0):\n",
+ " return mistakes[:-1]\n",
+ " else:\n",
+ " return mistakes + [Mistake(len(trace)+1, current)]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "def returns_to_origin(mistake_positions):\n",
+ " return [i for i, m in mistake_positions\n",
+ " if (m.x, m.y) == (0, 0)]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "sample_tours = ['FFLRLLFLRL', 'FLLFFLFFFLFFLFLLRRFR', 'FFRLLFRLLFFFRFLLRLLRRLLRLL']"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "def random_walk(steps=1000):\n",
+ " return ''.join(random.choice('FFLR') for _ in range(steps))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 15,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "def bounds(trace):\n",
+ " return (max(s.x for s in trace),\n",
+ " max(s.y for s in trace),\n",
+ " min(s.x for s in trace),\n",
+ " min(s.y for s in trace))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 16,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "plot_wh = {Direction.UP: (0, 1), Direction.LEFT: (-1, 0),\n",
+ " Direction.DOWN: (0, -1), Direction.RIGHT: (1, 0)}"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "def chunks(items, n=2):\n",
+ " return [items[i:i+n] for i in range(len(items) - n + 1)]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "def plot_trace(trace, colour='k', xybounds=None, fig=None, subplot_details=None, filename=None, show_axis=False):\n",
+ " if show_axis:\n",
+ " plt.axis('on')\n",
+ " else:\n",
+ " plt.axis('off')\n",
+ " plt.axes().set_aspect('equal')\n",
+ " for s, t in chunks(trace, 2):\n",
+ " w, h = plot_wh[t.dir]\n",
+ " plt.arrow(s.x, s.y, w, h, head_width=0.1, head_length=0.1, fc=colour, ec=colour, length_includes_head=True)\n",
+ " xh, yh, xl, yl = bounds(trace)\n",
+ " if xybounds is not None: \n",
+ " bxh, byh, bxl, byl = xybounds\n",
+ " plt.xlim([min(xl, bxl)-1, max(xh, bxh)+1])\n",
+ " plt.ylim([min(yl, byl)-1, max(yh, byh)+1])\n",
+ " else:\n",
+ " plt.xlim([xl-1, xh+1])\n",
+ " plt.ylim([yl-1, yh+1])\n",
+ " if filename:\n",
+ " plt.savefig(filename)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 19,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "def trim_loop(tour, random_mistake=False):\n",
+ " trace = trace_tour(tour)\n",
+ " mistakes = mistake_positions(trace)\n",
+ " if random_mistake:\n",
+ " end_mistake_index = random.randrange(len(mistakes))\n",
+ " else:\n",
+ " end_mistake_index = 0\n",
+ "# print('end_mistake_index {} pointing to trace position {}; {} mistakes and {} in trace; {}'.format(end_mistake_index, mistakes[end_mistake_index].i, len(mistakes), len(trace), mistakes))\n",
+ " # while this mistake extends to the next step in the trace...\n",
+ " while (mistakes[end_mistake_index].i + 1 < len(trace) and \n",
+ " end_mistake_index + 1 < len(mistakes) and\n",
+ " mistakes[end_mistake_index].i + 1 == \n",
+ " mistakes[end_mistake_index + 1].i):\n",
+ "# print('end_mistake_index {} pointing to trace position {}; {} mistakes and {} in trace'.format(end_mistake_index, mistakes[end_mistake_index].i, len(mistakes), len(trace), mistakes))\n",
+ " # push this mistake finish point later\n",
+ " end_mistake_index += 1\n",
+ " mistake = mistakes[end_mistake_index]\n",
+ " \n",
+ " # find the first location that mentions where this mistake ends (which the point where the loop starts)\n",
+ " mistake_loop_start = max(i for i, loc in enumerate(trace[:mistake.i])\n",
+ " if (loc.x, loc.y) == (mistake.step.x, mistake.step.y))\n",
+ "# print('Dealing with mistake from', mistake_loop_start, 'to', mistake.i, ', trace has len', len(trace))\n",
+ " \n",
+ " # direction before entering the loop\n",
+ " direction_before = trace[mistake_loop_start].dir\n",
+ " \n",
+ " # find the new instruction to turn from heading before the loop to heading after the loop\n",
+ " new_instruction = 'F'\n",
+ " if (mistake.i + 1) < len(trace):\n",
+ " if turn_left(direction_before) == trace[mistake.i + 1].dir:\n",
+ " new_instruction = 'L'\n",
+ " if turn_right(direction_before) == trace[mistake.i + 1].dir:\n",
+ " new_instruction = 'R'\n",
+ "# if (mistake.i + 1) < len(trace):\n",
+ "# print('turning from', direction_before, 'to', trace[mistake.i + 1].dir, 'with', new_instruction )\n",
+ "# else:\n",
+ "# print('turning from', direction_before, 'to BEYOND END', 'with', new_instruction )\n",
+ " return tour[:mistake_loop_start] + new_instruction + tour[mistake.i+1:]\n",
+ "# return mistake, mistake_loop_start, trace[mistake_loop_start-2:mistake_loop_start+8]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 20,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "def trim_all_loops(tour, mistake_reduction_attempt_limit=10):\n",
+ " trace = trace_tour(tour)\n",
+ " mistake_limit = 1\n",
+ " if trace[-1].x == 0 and trace[-1].y == 0:\n",
+ " mistake_limit = 0\n",
+ " mistakes = mistake_positions(trace)\n",
+ " \n",
+ " old_mistake_count = len(mistakes)\n",
+ " mistake_reduction_tries = 0\n",
+ " \n",
+ " while len(mistakes) > mistake_limit and mistake_reduction_tries < mistake_reduction_attempt_limit:\n",
+ " tour = trim_loop(tour)\n",
+ " trace = trace_tour(tour)\n",
+ " mistakes = mistake_positions(trace)\n",
+ " if len(mistakes) < old_mistake_count:\n",
+ " old_mistake_count = len(mistakes)\n",
+ " mistake_reduction_tries = 0\n",
+ " else:\n",
+ " mistake_reduction_tries += 1\n",
+ " if mistake_reduction_tries >= mistake_reduction_attempt_limit:\n",
+ " return ''\n",
+ " else:\n",
+ " return tour"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 21,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "def reverse_tour(tour):\n",
+ " def swap(tour_step):\n",
+ " if tour_step == 'R':\n",
+ " return 'L'\n",
+ " elif tour_step == 'L':\n",
+ " return 'R'\n",
+ " else:\n",
+ " return tour_step\n",
+ " \n",
+ " return ''.join(swap(s) for s in reversed(tour))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 22,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "def wander_near(locus, current, limit=10):\n",
+ " valid_proposal = False\n",
+ " while not valid_proposal:\n",
+ " s = random.choice('FFFRL')\n",
+ " if s == 'F':\n",
+ " proposed = advance(current, current.dir)\n",
+ " elif s == 'L':\n",
+ " proposed = advance(current, turn_left(current.dir))\n",
+ " elif s == 'R':\n",
+ " proposed = advance(current, turn_right(current.dir))\n",
+ " if abs(proposed.x - locus.x) < limit and abs(proposed.y - locus.y) < limit:\n",
+ " valid_proposal = True\n",
+ "# print('At {} going to {} by step {} to {}'.format(current, locus, s, proposed))\n",
+ " return s, proposed"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 23,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "def seek(goal, current):\n",
+ " dx = current.x - goal.x\n",
+ " dy = current.y - goal.y\n",
+ "\n",
+ " if dx < 0 and abs(dx) > abs(dy): # to the left\n",
+ " side = 'left'\n",
+ " if current.dir == Direction.RIGHT:\n",
+ " s = 'F'\n",
+ " elif current.dir == Direction.UP:\n",
+ " s = 'R'\n",
+ " else:\n",
+ " s = 'L'\n",
+ " elif dx > 0 and abs(dx) > abs(dy): # to the right\n",
+ " side = 'right'\n",
+ " if current.dir == Direction.LEFT:\n",
+ " s = 'F'\n",
+ " elif current.dir == Direction.UP:\n",
+ " s = 'L'\n",
+ " else:\n",
+ " s = 'R'\n",
+ " elif dy > 0 and abs(dx) <= abs(dy): # above\n",
+ " side = 'above'\n",
+ " if current.dir == Direction.DOWN:\n",
+ " s = 'F'\n",
+ " elif current.dir == Direction.RIGHT:\n",
+ " s = 'R'\n",
+ " else:\n",
+ " s = 'L'\n",
+ " else: # below\n",
+ " side = 'below'\n",
+ " if current.dir == Direction.UP:\n",
+ " s = 'F'\n",
+ " elif current.dir == Direction.LEFT:\n",
+ " s = 'R'\n",
+ " else:\n",
+ " s = 'L'\n",
+ " if s == 'F':\n",
+ " proposed = advance(current, current.dir)\n",
+ " elif s == 'L':\n",
+ " proposed = advance(current, turn_left(current.dir))\n",
+ " elif s == 'R':\n",
+ " proposed = advance(current, turn_right(current.dir))\n",
+ " \n",
+ "# print('At {} going to {}, currently {}, by step {} to {}'.format(current, goal, side, s, proposed))\n",
+ "\n",
+ " return s, proposed"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 24,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "def guided_walk(loci, locus_limit=5, wander_limit=10, seek_step_limit=20, return_anyway=False):\n",
+ " trail = ''\n",
+ " current = Step(0, 0, Direction.RIGHT) \n",
+ " l = 0\n",
+ " finished = False\n",
+ " while not finished:\n",
+ " if abs(current.x - loci[l].x) < locus_limit and abs(current.y - loci[l].y) < locus_limit:\n",
+ " l += 1\n",
+ " if l == len(loci) - 1:\n",
+ " finished = True\n",
+ " s, proposed = wander_near(loci[l], current, limit=wander_limit)\n",
+ " trail += s\n",
+ " current = proposed\n",
+ "# print('!! Finished loci')\n",
+ " seek_steps = 0\n",
+ " while not (current.x == loci[l].x and current.y == loci[l].y) and seek_steps < seek_step_limit:\n",
+ "# error = max(abs(current.x - loci[l].x), abs(current.y - loci[l].y))\n",
+ "# s, proposed = wander_near(loci[l], current, limit=error+1)\n",
+ " s, proposed = seek(loci[l], current)\n",
+ " trail += s\n",
+ " current = proposed\n",
+ " seek_steps += 1\n",
+ " if seek_steps >= seek_step_limit and not return_anyway:\n",
+ " return ''\n",
+ " else:\n",
+ " return trail"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 25,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "image/png": "iVBORw0KGgoAAAANSUhEUgAAAQEAAAD7CAYAAABqkiE2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAACUdJREFUeJzt3Wty3MYRAOBePSzJejgP29EFcpccILfMCVL5lZ85Q0qJ\nEjt2LDuOI1tWZIpEfnBQRrZWohZSjxs731fF4haxAIYAd4ju6QF20zQFMK5rP3UDgJ+WTgAGpxOA\nwekEYHA6ARicTgAGpxOAwd3otaPdbvebiPh1REwRsWvfIyKuR8R5RLyMiJuLn0d73y4iLtryW+29\n8zautddTW367fb9oy66311Nb73ZEnC2WL7c/xeXxOG9fN/baut+W9xbrzW2J9rOztq/zxb5e1dbz\n1s7l9s/b7zovn89TRlsPHbf9tt5pv9Pc1uXyi7b9ZVun9p6Lxf7mczy3Z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z6rE4KpxxWMt6gT+uNvt7kXEXyLio4i4GRHPIuL9iPgiIn4ZEXfb8l9FxO2I\n+Doi7kXENxHxoP3sb2353Yj4Z/v5fyPivYi4FRF/j4iHbb1PI+JncdlLXrT1P23r34+Ix22/1yPi\neWvL56199yPiUUR83Lb9tO3zq4j4eXvvX9u23o+IJ60tT9u+b7W2PmzrfR4RH0TED21/tyPik7b+\nvdbuX8TlyTyLiDuLtj5obfkoLs/bs8Xv/2Fb/9Hecbvfvn/QtvV4r633I+L79v61x+1aRLxo2/+s\nHav94/Zt2+eX7fdbnuM77Xje3zvHjw8ctxdx+Tez39ZP2vmIuLzt9vK43W/n6MNXnOP57/Hjtt3/\n7J3j5XG7036HBxHxXdvO3Jb57/GzdtxetvN4q7Vvbuuhc/yPxXGb23qz7eNu/P9n41Hb1qHPxsNY\nY5qm9K+4/EP5U1z+QU3tQE97X98tXv/rwPKLxesnB5ZPr1h+fmD5l4vX3x9Y/s3i9b8PLH++eP3V\nEW059PXF4vUPB5Yvt//tgeVPrzhuZyvbcuhredyeH1j+9RXn+NkRx+2qtiyXv7yirc8OLL/qHL94\nxbbWnOMnr9juofP29MDyYz4bfzj287kz1R/GZnQABqcTgMHpBGBwOgEYnE4ABqcTgMHpBGBwOgEY\nnE4ABqcTgMHpBGBwOgEYnE4ABqcTgMHpBGBwOgEYnE4ABqcTgMHpBGBwOgEYnE4ABqcTgMH9D868\nJ7EMO+IfAAAAAElFTkSuQmCC\n",
+ "text/plain": [
+ "<matplotlib.figure.Figure at 0x7fdea71b8cc0>"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "def square_tour(a=80):\n",
+ " \"a is width of square\"\n",
+ " return ('F' * a + 'L') * 4\n",
+ "\n",
+ "plot_trace(trace_tour(square_tour()))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 26,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "image/png": "iVBORw0KGgoAAAANSUhEU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bCHE4zoC5XyCRcUsJoR4PCflvI9FxSx++eKxqFjOb7ComMWEoHl2HRNsFouK8VhULGcF18rM\nYgshHv9FK+cOFhWzmBDi8bl5OR8Aa7WDGBITQjw+diznM1yXIYsJQfPsEq7LkMWiYjwWwcq5AJyv\nHcSQ2EKIx1uGcj7CtR2zmBDisahYzjomhCwmhHhsIZRzD4uKWawhxOO6DOUsY0evLLYQ4jlTO4A5\n8hppBWjNyIQQz/PaAcyRW1hDyGJCiMcmbjk3cV2GLNYQ4rGoWM4mJoQsJoR4nPKrnAMs0mbxliGe\n5doBzJE1XKgliwkhHpcvL8eiYiYTQjy2EMq5SVoSXjOyhhCPRcVyvgSe1A5iSEwI8VgEK+cpsFU7\niCHxliEebxnKuY6DxbKYEOLZrR3AHPkI51TMYkKIx56K5ayTZk3SjKwhxONz83Ke4eCmLCYEzbMH\nwKPaQQyJtwzxWAQr500cTp7FhBCP/RDKsaiYqWlbH3tH0TRNC/wMuA1cBg5JHWvWSF1wL5AGPz0C\nrpGaxOdJt36b3bbHpCXMFrvXXCM9jx/NHrTRHe9Zd6yzpIvmCukJx373PveBq6QEtU2abGSji+uA\n1OnnarftEqn/xCjWUVyTsW5277XQ/fdat//KxLZVUr+BpS7e+91+291ncX4irt3uz8Uuhte62Cdj\n/THwu7Zt38g6ESeYLYRY/hX4EfDHHFXHt4BzEz8hXWSXSZOprHTbHpAulEOOakMbfH059NFFNumb\n9hsdb9JD0sUG6WJcJl3UF7ttT0nJ5Bnp4p98zWj/yfdrORrd+YfEuklKaHD09x/VDv4ezcwWgqQx\nnzJIGjMhSBozIUgaMyFIGjMhSBozIUgaMyFIGjMhSBozIUgaMyFIGjMhSBozIUgaMyFIGjMhSBoz\nIUgaMyFIGjMhSBozIUgaMyFIGjMhSBozIUga+39B5c93LYMfSQAAAABJRU5ErkJggg==\n",
+ "text/plain": [
+ "<matplotlib.figure.Figure at 0x7fdea71dde10>"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "def cross_tour(a=50, b=40):\n",
+ " \"a is width of cross arm, b is length of cross arm\"\n",
+ " return ('F' * a + 'L' + 'F' * b + 'R' + 'F' * b + 'L') * 4\n",
+ "\n",
+ "plot_trace(trace_tour(cross_tour()))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 27,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "image/png": "iVBORw0KGgoAAAANSUhEUgAAAQYAAAD7CAYAAACITjpPAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAEFZJREFUeJzt3dlu3Fh6wPE/ZXmRvMptq213Ty/TeYQACQYI0sAgGCB5\nh7xBLvMAAXKVB8gjJJcBgrmam1xOggFmECC57CW9WYslWba8SJbNXBwSVSZFntKwVDws/n+AIJWL\ndXyKy1eHXx1+zPI8R5KmrfTdAUnpMTBIqjEwSKoxMEiqMTBIqjEwSKpZ7bsDAFmW/Rr4c+ADYB/Y\nBj4GbgI/Ac+Az4ErwP8Bp8AXwFvg6+LfPwOOi8e3gUfAEfAd8OE52n4D/ElD298AtyptbwL3gANg\nC/ioWOYxcFi89uoZbX9DWP+fn9H2C+B3wC/zPH/3R69YkWXZXwD/QVi/K8DPgRPgK8I+8DHwEviW\nsB03CdvtR8K2uEPYZw6AT4E1wnZ/XbSVndH218CNhrafAT9Mtb1D2C8/AdaB74FXU21/W/w+q+1X\nxf/9AWEff168/iGwUbS9V7R9vdL23+Z5/q9N6y2JwAD8DfC/wFPCm9snHDzXCG/sVbHcJcJGyouf\nd4QD8Erx+HXx+Kh4zeti+ZOi7aOivVPCBt4nbLjptssD8R3hQF+ttP2s0vYxYUc6qvQ71nbZb4q2\ntiptf0nY4LuzrkSd6Z8J6//H4jeE/aHclm8I6/xx8fuIEJh3CdtyjxAUjgjb7QrhgDst2soJ2/ZS\n8feboq31qba3zmj7tKHt3eJ15QSjbULQOavt11NtvyDsbztTbR8W7zGvtP0Z8C9A8oEB4K/yPH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3T3A0m5V\nt4C7bQukFBhS6ksqXCfdXcPp9lUbhDxDo5ROJfx0rDPH0J3l4+teYfn4QTPH0N0bLB9fZfn4gTMw\ndPch5hiqLB8/cAbL7lLax1NxA8vHa+S2McdQdUgo79YopWjqsLnOEUN3K6T1AZiCQyL3lUgpMDhi\nqPNrtu7uA5/03YnE3GdAU6ItH19nsOzuHa7HqkGVj/c7+zpPr7rbxlvUVe0xoKsrPZ/WRbiG5eOr\njgnXkDRKKTCozu3T3V0sH181qPLxKZ3WpMLy8d0dE7nEeIQyIsdbSgejB0FdSoF7qCwfX7dD5NhP\naccz0aaLsEEYOmsiJ5LTSykwqM5g2d0NTD5WPSJy/UhKpxKbWZatEL62LCPaKuE76Kz498uEU47y\ngMmmll3h/UhYtlW+9tLU801tvy2ey6b+nQtoe2Xq+ayhbfAr3Hk4Ap5lWfaQ5vXdtm1XeX+fnN4H\nc8K2L5+fbqtt2/6xbTP1+mzq75z395v8jLan98mcyKl7SoHhD313IEHec7G73wJ/CvzUd0cS829t\nT2Z57vQBSe8zxyCpxsAgqcbAIKnGwCCpxsAgqcbAIKnGwCCpxsAgqcbAIKnGwCCpxsAgqcbAIKnG\nwCCpxsAgqcbAIKnGwCCpxsAgqcbAIKnGwCCpxsAgqcbAIKnm/wGyPjyrfbBoQAAAAABJRU5ErkJg\ngg==\n",
+ "text/plain": [
+ "<matplotlib.figure.Figure at 0x7fdea6f8a160>"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "def quincunx_tour(a=60, b=30, c=50):\n",
+ " \"a is length of indent, b is indent/outdent distance, c is outdent outer length\"\n",
+ " return ('F' * a + 'R' + 'F' * b + 'L' + 'F' * c + 'L' + 'F' * c + 'L' + 'F' * b + 'R') * 4\n",
+ "plot_trace(trace_tour(quincunx_tour()))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 28,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "image/png": "iVBORw0KG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DnAScDCyNiFPKRjR9uenuscBhwJ4u3Iw/J0qrlKTXANd3PfWWiLiwVDyDcNPd\n9vE1SqtURNzQ0/x3y6IBDe5zbrrbHk6UVtq/54LI2aUDmYyk3+op3Py0aEBWKRdzrKTtSfcL/zvg\nDwrH0s+ueXsUacVRq5Zmtp2vUVpxkn5CqobfAlwbEe8tHNIakvYlTZLfHpjvwk07OVFacZJeC1wI\nrJ+f2iwiHisX0fN6CjeXRMQbigVjxThRWq3kxLQ58BiUb/6b47k7Il5WMg4ry8Ucq42u5r+Pkpr/\nnloojlk9hZvzS8Rh9eERpdWKpDmk+++sIE1In1cojgA2JjXdfbL0yNbK8ojSaiUino2IJ/LDF+eR\n3QVV7FvSwZKWdo0kn4yIJ5wkzYnS6uog4FZgGfCWivb578Bc0q0svj6uvTNt+nzqbbWWp+dcBRzS\n86kgtXDrbFcBc/J2NWkQsApYD3iu67mJXqPzudOB7T0FyHp5wrnV3QN5e3lF+/PtG+w3eERpZtaH\nr1GamfXhRGlm1ocTpZlZH06UZmZ9OFGamfXhRGlm1ocTpZlZH06UZmZ9OFGamfXhRGlm1ocTpZlZ\nH06UZmZ9OFGamfXhRGlm1ocTpZlZH06UZmZ9OFGamfXhRGlm1ocTpZlZH06UZmZ9OFGamfXhRGlm\n1sd/Aw+RJa+eq45oAAAAAElFTkSuQmCC\n",
+ "text/plain": [
+ "<matplotlib.figure.Figure at 0x7fdea6d354e0>"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "heart_points = [Step(60, 50, Direction.UP), Step(50, 90, Direction.UP),\n",
+ " Step(20, 70, Direction.UP), \n",
+ " Step(-40, 90, Direction.UP), Step(-60, 80, Direction.UP), \n",
+ " Step(0, 0, Direction.RIGHT)]\n",
+ "\n",
+ "heart_tour = ''\n",
+ "current = Step(0, 0, Direction.RIGHT)\n",
+ "\n",
+ "for hp in heart_points:\n",
+ " while not (current.x == hp.x and current.y == hp.y):\n",
+ " s, proposed = seek(hp, current)\n",
+ " heart_tour += s\n",
+ " current = proposed\n",
+ "\n",
+ "plot_trace(trace_tour(heart_tour))\n",
+ "\n",
+ "def heart_tour_func(): return heart_tour"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 29,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "def trim_some_mistakes(tour, mistake_limit):\n",
+ " trimmed_tour = rw\n",
+ " mistake_count = len(mistake_positions(trace_tour(trimmed_tour)))\n",
+ " while len(mistake_positions(trace_tour(trimmed_tour))) > mistake_limit:\n",
+ " trimmed_tour = trim_loop(trimmed_tour, random_mistake=True)\n",
+ " return trimmed_tour"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 68,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "10"
+ ]
+ },
+ "execution_count": 68,
+ "metadata": {},
+ "output_type": "execute_result"
+ },
+ {
+ "data": {
+ "image/png": "iVBORw0KGgoAAAANSUhEUgAAAUQAAAEACAYAAADLIw+8AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAACDFJREFUeJzt20+o5WUdx/HPN2d0/JMTWpEpRi2CIIxw0UI3bTQirDZm\nm8IsiqjIwspFUVkW6S7aBJLtpHSlNZbRpiIjKNBol2GZZjmmptOIOk+L33fymg7i3HPnuffM6wXD\nvefMLD4wZ973+Z3zmxpjBIDkZbMHAGwXggjQBBGgCSJAE0SAJogATRABmiACNEEEaIII0AQRoAki\nQBNEgCaIAE0QAZogAjRBBGiCCNAEEaAJIkATRIAmiABNEAGaIAI0QQRoggjQBBGgCSJAE0SAJogA\nTRABmiACNEEEaIII0AQRoAkiQBNEgCaIAE0QAZogAjRBBGiCCNAEEaAJIkATRIAmiABNEAGaIAI0\nQQRoggjQBBGgCSJAE0SAJogATRABmiACNEEEaIII0AQRoAkiQBNEgCaIAE0QAZogsiWqandVXVFV\nd1TV3tl7Vq2q9lbVl6vqptlbWJ1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aAJIkATRIAmiABN\nEAGaIAI0QQRoggjQBBGgCSJAE0SAJogATRABmiACNEEEaIII0AQRoAkiQBNEgCaIAE0QAZogAjRB\nBGiCCNAEEaAJIkATRIAmiABNEAGaIAI0QQRoggjQBBGgCSJAE0SAJogATRABmiACNEEEaIII0AQR\noAkiQBNEgCaIAE0QAZogAjRBBGiCCNAEEaAJIkATRIAmiABNEAGaIAI0QQRoggjQBBGgCSJAE0SA\nJogA7b/FLob4OhrHyQAAAABJRU5ErkJggg==\n",
+ "text/plain": [
+ "<matplotlib.figure.Figure at 0x7fdea6b5b1d0>"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "plot_trace(trace_tour(sample_tours[0]))\n",
+ "len(sample_tours[0])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 31,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "image/png": "iVBORw0KGgoAAAANSUhEUgAAAN4AAAEACAYAAADcJMhcAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAACXdJREFUeJzt3WuoZXUdh/HnN86MioaJhUmaRVGBdhG62EV7YVjEJHTR\nksQwDSExM0zTTI1SK6KbVmSpBNLFDC1vJYWCFipJWoploJahRgZW3mecXy/WmuZ4ozqjfteZ9Xxg\nw94HYb6cs5+91jkv/Fd3I+nptSw9QJojw5MCDE8KMDwpwPCkAMOTAgxPCjA8KcDwpADDkwIMTwow\nPCnA8KQAw5MCDE8KMDwpwPCkAMOTAgxPCjA8KcDwpADDkwIMTwowPCnA8KQAw5MCDE8KMDwpwPCk\nAMOTAgxPCjA8KcDwpADDkwIMTwowPCnA8KQAw5MCDE8KMDwpwPCkAMOTAgxPCjA8KcDwpADDA6pq\n86rav6q2Tm9Zp6qWVdW7quqF6S0LVdVuVfWG9I6lbtbhjcF9FLgdOB3YKzxpXXD7ADcDPwCODE8C\n/hPclcAvgG+m9yx11d3pDRFV9SrgMmATYDNgL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4UYHhSgOFJAYYnBRieFGB4UoDhSQGGJwUYnhQwu/CqallVfQNYNb4+u6qeHx2l\n2ZldeAzHL++34PU7gReEtmimZhded98HnATcN37pt8BlqT1VdWxVHVRVK1IbHq2q3lNVJ1TVVukt\n61TVLlX1taraIb3lyTC78EanMBxz/ABwRGdP5zyM4ejlv0wowAOBYxg2TSXAtwAHAzdV1RnpMRtq\nzifCfgo4Lr3jURqY2gm1a4GHGG7R09Z9f9YyXDTe0d3nZSctzmzDA6iqlwErwzMuZzjPezXwPeB0\n4MHoouGo450Z7giuYDhz/O7oIvgQcADDKbB/Ao7s7ouykxZv+X//TzZe3f279IaqupjhTX1Cd9+W\n3gNQVT8E7gSO6u7fpPcAVNU5wCuAY4GfhX892GCzvuJJKXP944oUZXhSgOFJAYYnBRieFGB4UoDh\nSQGGJwUYnhRgeFKA4UkBhicFGJ4UYHhSgOFJAYYnBRieFGB4UoDhSQGGJwUYnhRgeFKA4UkBhicF\nGJ4UYHhSgOFJAYYnBRieFGB4UoDhSQGGJwUYnhRgeFKA4UkBhicFGJ4UYHhSgOFJAYYnBRieFGB4\nUoDhSQGGJwUYnhRgeFKA4UkBhicFGJ4UYHhSgOFJAYYnBRieFGB4UoDhSQH/Bj2f02NVdfZHAAAA\nAElFTkSuQmCC\n",
+ "text/plain": [
+ "<matplotlib.figure.Figure at 0x7fdea6ff01d0>"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "plot_trace(trace_tour(sample_tours[1]))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 32,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "image/png": "iVBORw0KGgoAAAANSUhEUgAAASMAAAEACAYAAAD4GBC1AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAACyxJREFUeJzt3W2spHdZx/Hvr552d8v2KV2FtkELGGwgkKLUB4Lb8sKm\nGB8SFXVfaGJB1FKrCUrarRV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v/nOSFg1fS\nUzBGW+sY8IL5/lFg51KDkyw2q7ENpst6A1zG9PNYhK//6TNGW6iqPsd0bfsn5ts7lpib5Dzg4SR/\nnuSlS8xs6t3AI0ABf1hVB5YYmmQfcDDJncDZS8xcBamq0TustCTPBD7NmEuJF3CE6UR2RVX9/YAd\nhkryo8CvDhi9yXQa3gA2qioDdthWRrxB1kpVfW7+S/lzC47dDXwVU4g2gV8DPrLg/E7eBbwIWPJa\n98e/m3oSeBjYv+DsbcuT0QpKshv4O+ADwFur6qHBK62VJFcDdzH9Afrtqlrsu6rtzBhJasEvsCW1\nYIwktWCMJLVgjCS1YIwktWCMJLVgjCS1YIwktWCMJLVgjCS1YIwktWCMJLVgjCS1YIwktWCMJLVg\njCS1YIwktWCMJLVgjCS1YIwktWCMJLVgjCS1YIwktWCMJLVgjCS1YIwktWCMJLVgjCS1YIwktWCM\nJLVgjCS1YIwktWCMJLVgjCS1YIwktWCMJLVgjCS1YIwktWCMJLVgjCS1YIwktWCMJLVgjCS1YIwk\ntWCMJLVgjCS1YIwktWCMJLVgjCS1YIwktfDfe+gKnnXxV4YAAAAASUVORK5CYII=\n",
+ "text/plain": [
+ "<matplotlib.figure.Figure at 0x7fdea700c4e0>"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "plot_trace(trace_tour(sample_tours[2]))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 40,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "['FLRFRFFFRFFFRFFR',\n",
+ " 'FFFRFRFRLR',\n",
+ " 'FFFFRFRFRLFR',\n",
+ " 'FFFLFFLFFLFF',\n",
+ " 'FFRRFLRRFR',\n",
+ " 'RLRFFRFRFFFR',\n",
+ " 'LFRFLLFFFLFFLF',\n",
+ " 'RLFFLFLFLR',\n",
+ " 'RFFFLLRFFFLLRRLLFFFF',\n",
+ " 'FLFFLFFLFLRL']"
+ ]
+ },
+ "execution_count": 40,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "samples = []\n",
+ "while len(samples) < 10:\n",
+ " t = valid_prefix(random_walk())\n",
+ " if len(t) > 8 and len(t) < 25:\n",
+ " samples += [t]\n",
+ "samples"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 43,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAEACAYAAACwB81wAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAACaRJREFUeJzt2m2o5nldx/HPd/Zu1t1ctS1voRS8CVSIiu7YjEx9YndE\nQvnAniQEoQibwYBi1gqyLII9CKIHkVAUm6gkK4hsbA90AxFiRZJYEnNrc8V2mN2Zmt3z7cF1DTMt\naTtnrjm/M9f39YJhz3XYgc+fOefN7/zOVd0dAPbfidUDADgagg8whOADDCH4AEMIPsAQgg8whOAD\nDCH4AEMIPsAQgg8whOADDCH4AEMIPsAQgg8whOADDCH4AEMIPsAQgg8whOADDCH4AEMIPsAQgg8w\nhOADDCH4AEMIPsAQgg8whOADDCH4AEMIPsAQgg8whOADDCH4AEMIPsAQgg8whOADDCH4AEMIPsAQ\ngg8whOADDCH4AEMIPsAQgg8whOADDCH4AEMIPsAQgg8whOADDCH4AEMIPsAQgg8whOADDCH4AEMI\nPsAQgg8whOADDCH4AEMIPsAQgg8whOADDCH4AEMIPsAQgg8whOADDCH4XLaq+lhV/UFVPW/1ll2r\nqlur6rNV9c6qunH1nl2rqldV1f1V9daqqtV7dq2q3lJVn6mqH1m95TgSfA7jF5PcmeRf9zD8tyV5\nQ5J7snm+fQv/a5L8ZJK/TPKVPQz/TyV5S5IHqupzwv+/VXev3jBGVb0iyfNX79iBzye5Yfvx2SQH\nST6S5NNJzq8atSMvSvI3SW7avj6TzTO+P8mXkjy1aNeu/HySU0meu319Jsk3krwvycOrRu3Qe5K8\nfftxZ/Nv94Ukp7r7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uvvjSV6Z5B1JHs7me+hg6bAd\n6e5z3f3RJC9JcirJt3PxF57sASd8OKTtif+F3b2XVz3bE/8t3f2t1VvYDcEHGMKVDsAQgg8whOAD\nDCH4AEMIPsAQgg8whOADDCH4AEMIPsAQgg8whOADDCH4AEMIPsAQgg8whOADDCH4AEMIPsAQgg8w\nhOADDCH4AEMIPsAQgg8whOADDCH4AEMIPsAQgg8whOADDCH4AEMIPsAQgg8whOADDCH4AEMIPsAQ\ngg8whOADDCH4AEMIPsAQgg8whOADDCH4AEMIPsAQgg8whOADDCH4AEMIPsAQgg8whOADDCH4AEMI\nPsAQgg8whOADDCH4AEMIPsAQgg8whOADDCH4AEMIPsAQgg8whOADDCH4AEMIPsAQgg8whOADDCH4\nAEMIPsAQgg8whOADDCH4AEMIPsAQgg8whOADDCH4AEP8D59AFpXbgft5AAAAAElFTkSuQmCC\n",
+ "text/plain": [
+ "<matplotlib.figure.Figure at 0x7fdea6ba2c50>"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "plot_trace(trace_tour(samples[2]))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 44,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "1"
+ ]
+ },
+ "execution_count": 44,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "mistakes = [t.strip() for t in open('tours-random-walk.txt').readlines()\n",
+ " if len(t) > 8\n",
+ " if len(t) < 26]\n",
+ "len(mistakes)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 45,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "image/png": "iVBORw0KGgoAAAANSUhEUgAAAQMAAAEACAYAAAC3RRNlAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAABydJREFUeJzt3U+o9XldwPH3x+axNEpwEBSdCO0PghCG6MI/S5HAoF0h\n1CJIIm2VtHCgbBP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a679O\nMO+t1f3Vu9ZaXz7BvN+svlw9tNY6dniamXdXf199aF/uHXPWfdVD1SeqP1xrPXXMeXdLDIDKDURg\nEwOgEgNgEwOgEgNgEwOgEgNgEwOgEgNgEwOgEgNgEwOgEgNgEwOgEgNgEwOgEgNgEwOgEgNgEwOg\nEgNgEwOgEgNgEwOgEgNgEwOgEgNgEwOgEgNgEwOgEgNgEwOgEgNgEwOgEgNgEwOgEgNgEwOgEgNg\nEwOgEgNgEwOgEgNgEwOgEgNgEwOgqv8F9Hl5y6i1C9AAAAAASUVORK5CYII=\n",
+ "text/plain": [
+ "<matplotlib.figure.Figure at 0x7fdea7040b70>"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "plot_trace(trace_tour(mistakes[0]))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 48,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "(212,\n",
+ " 94,\n",
+ " 'FFRFLLFFFRLRRFFFLFLRRFLLFFFFFRFLFFFFFRLLFRFRLLFFFFFFLRFFRLLFRFFFLFFLFFRFRRLLFFRLFFFFFLLFFRFRFL')"
+ ]
+ },
+ "execution_count": 48,
+ "metadata": {},
+ "output_type": "execute_result"
+ },
+ {
+ "data": {
+ "image/png": "iVBORw0KGgoAAAANSUhEUgAAAP4AAAEACAYAAACTecuMAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAADo5JREFUeJzt3X/sZFV5x/HPs1+oLt0VDVn4sgILSlfMgkqVttjY9Mcq\nglJJV9GUosTaKAbLP7VNSZo0TYox9o/WNqXxRzSm2taGYkzRYktUSNhKu1JpgSylZYGybEAbYXdl\nF9h9+sec0cGuzDmzc+acO8/7lXxzL8k5c57Lnc/Mnc0595q7C0Asa1oXAGDxCD4QEMEHAiL4QEAE\nHwiI4AMBEXwgIIIPBETwgYAIPhAQwQcCIvhAQAQfCIjgAwERfCAggg8ERPC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q7eCulfTlwj63S/rj\nCrV0y93Hi0fuLuh2plTvmy89f2CrpG/XeP0Jpef7PkkqWP8xXhl6QUlRQ9PVN76775N0UW57M1tx\n95yFMFjAk2Hc/WZJJ+a2Lz1/M57v0vsojD8glnopb2/f+EUIfZHxAzVqLmEuUnr+FnG+3X28JPxL\ntcdqadDBBzAbgg8ERPCBgAg+EBDBBwIi+EBABB8IiOAPkJmNz9vLmxYyDK9oXUCPupq5h2xnp+3P\nmdmrM9q/VtJZFevp2WmSZGavl/S/U9q+QNJ7qlfUAav07ANUdDQPlnD3rAdLLAszu0LSpwq77Zd0\nUk+zHOeN4AeQHghylqSv1HrKzTJIS4svkfSP7v5463pqIvhAQPzjHhAQwQcCIvhAQAQfCIjgAwER\nfCAggg8ERPCBgAg+EBDBBwIi+EBABB8IiOADARF8ICCCDwRE8IGACD4QEMEHAiL4QEAEHwiI4AMB\nEXwgIIIPBETwgYAIPhAQwQcCIvhAQAQfCIjgAwERfCAggg8E9H9g3ys8YjIz8gAAAABJRU5ErkJg\ngg==\n",
+ "text/plain": [
+ "<matplotlib.figure.Figure at 0x7fdea7095780>"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "lc = trace_tour(square_tour(a=10))\n",
+ "rw = guided_walk(lc, wander_limit=4, locus_limit=2)\n",
+ "rw_trimmed = trim_all_loops(rw)\n",
+ "plot_trace(trace_tour(rw_trimmed))\n",
+ "len(rw), len(rw_trimmed), rw_trimmed"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 66,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "['LFLLFFFFLLLFFRFRFF',\n",
+ " 'LFFLLFFL',\n",
+ " 'FRFFRRFFFFFFLLRLRLRLLFFF',\n",
+ " 'RFFRRRFLFFFFLFLFRLLF',\n",
+ " 'LFFRFRFFFFFRFFRLRFRF',\n",
+ " 'LFFRFRFRFL',\n",
+ " 'FLFFLLFFRLLL',\n",
+ " 'FLLFFLLF',\n",
+ " 'FFLLRLRLLFLR',\n",
+ " 'FRRLLFLFFFFLFFFLLFFRRFLL',\n",
+ " 'FRFRRFFF',\n",
+ " 'FFFRFRRFFFFFFLFLFFFLRR',\n",
+ " 'FFRRRFFLRLFRLFLFLFRFLF',\n",
+ " 'RFFRRFFR',\n",
+ " 'LFFFFRRRFLFFFL',\n",
+ " 'FFLLLRRLLL',\n",
+ " 'FFRFFRFRFRLL',\n",
+ " 'RFLFFFFRRFFFFFRFFLLLLR',\n",
+ " 'RRLLRRFFRFRFLR',\n",
+ " 'FFRFRFFRFR']"
+ ]
+ },
+ "execution_count": 66,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "mistakes = []\n",
+ "while len(mistakes) < 20:\n",
+ " lc = trace_tour(square_tour(a=8))\n",
+ " rw = guided_walk(lc, wander_limit=4, locus_limit=2)\n",
+ " rw_trimmed = trim_some_mistakes(rw, 2)\n",
+ " if len(rw_trimmed) > 6 and len(rw_trimmed) < 25:\n",
+ " mistakes += [rw_trimmed]\n",
+ "mistakes"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 67,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "317"
+ ]
+ },
+ "execution_count": 67,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "open('mistakes.txt', 'w').write('\\n'.join(mistakes))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 69,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "137"
+ ]
+ },
+ "execution_count": 69,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "open('samples.txt', 'w').write('\\n'.join(samples))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 71,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "('FFRRFLRRFR', 10)"
+ ]
+ },
+ "execution_count": 71,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "samples[4], len(samples[4])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 83,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "('RRLLRRFFRFRFLR', 14)"
+ ]
+ },
+ "execution_count": 83,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "mistakes[18], len(mistakes[18])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 74,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'RRFFLLFFFFLF'"
+ ]
+ },
+ "execution_count": 74,
+ "metadata": {},
+ "output_type": "execute_result"
+ },
+ {
+ "data": {
+ "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAADgCAYAAAAANN1GAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAACEVJREFUeJzt2l+IpXUdx/HPV1dXbTcoRDSSbLEiyRI1WrEuLMgEiSCI\npIiIMrqpGyuyP4SYkIGElNhN2U1U9IeiQiTTLqyklQQxiv5QEbJloeWurmvtr4vnLE4i7sy4s8+c\n+b5eMMw5M7vwmcM573nmeU6NMQLA1nfc3AMAODYEH6AJwQdoQvABmhB8gCYEH6AJwQdoQvABmhB8\ngCYEH6AJwQdoQvABmhB8gCYEH6AJwQdoQvABmhB8gCYEH6AJwQdoQvABmhB8gCYEH6AJwQdoQvAB\nmhB8gCYEH6AJwQdoQvABmhB8gCYEH6AJwQdoQvABmhB8gCYEH6AJwQdoQvABmhB8gCYEH6AJwQdo\nQvABmhB8gCYEH6AJwQdoQvABmhB8gCYEH6AJwQdoQvABmhB8gCYEH6AJwQdoQvABmhB8gCYEH6AJ\nwQdoQvABmhB8gCYEHzaBqjqlqrwe2VCeYLA5/DLJ5+Ye0VFV7aqqf1TVBXNv2WiCD5vDOUkunntE\nU9ckeV6S6+cestEEH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ITg\nAzQh+ABNCD5AE4IP0ITgAzQh+ABNCD5AE4IP0ITgAzQh+ABNCD5AE4IP0ITgAzQh+ABNCD5AE4IP\n0ITgAzQh+ABNCD5AE4IP0ITgAzQh+ABNCD5AE4IP0ITgAzQh+ABNCD5AE4IP0ITgAzQh+ABNCD5A\nE4IP0ITgAzQh+ABNCD5AE4IP0ITgAzTxP30j0UaD36R4AAAAAElFTkSuQmCC\n",
+ "text/plain": [
+ "<matplotlib.figure.Figure at 0x7fdea6e5cac8>"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "t = trim_all_loops(random_walk(20))\n",
+ "plot_trace(trace_tour(t))\n",
+ "t"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 76,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "t2 = 'FFRFLLFFFRLRRFFFLFLRRFLLFFFFFRFLFFFFFRLLFRFRLLFFFFFFLRFFRLLFRFFFLFFLFFRFRRLLFFRLFFFFFLLFFRFRFL'\n",
+ "t2a = t2[:51]\n",
+ "t2b = t2[51:]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 80,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'FFRFLLFFFRLRRFFFLFLRRFLLFFFFFRFLFFFFFRLLFRFRLLFFFFF'"
+ ]
+ },
+ "execution_count": 80,
+ "metadata": {},
+ "output_type": "execute_result"
+ },
+ {
+ "data": {
+ "image/png": "iVBORw0KGgoAAAANSUhEUgAAAMwAAAEACAYAAAD/f5mJAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAACT5JREFUeJzt3V2IbWUdx/Hf78yhFzM7YmXJeYlOGJSZlQYK3VQq2REk\nDYkKjKK60i6NoKsovAsKIrookLroIiizkowKQUmttAwJLT1qqcfeTnl8qTPz72KeXYOUe/3GvebZ\na+b7gcNewlqz/lP7Oy/Mw7NcVQ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ODZzpxHZ4kqSx9g37kqQ3acRH99m+QtJXw8uO2T61qo4N\nPP8OSX8M7zEpSxVMVT1t+6CkkwdecpWkb2v4jpHnSbpS0ruDsS5vr1dI+mRwXeKYpBcHb8zNmMVy\nvqS/zjn3JEkflvT+djx3rvbF7ixJZ23njfx23FOUbV8n6dDQJxbb3qP1N9ibq2rIzpebmeliSd8Z\n8ynKtg9L2p/co219e9rQHTnb+ZN/fPqzmfTvMFuhqv7WDqe+Qd2vtug+U//f6VkRDBAgGCBAMECA\nYIAAwQABggECBAMEdmIwhyTJ9ot6D7LBpZJk+/R5J7bz0qVAMdvntcOLxr7XlCzV0pgtcoeCPcY2\nLNQc84vLbP3Vb4euC7X9C0lnaH17ozHMvqAkS0Ge0H8first7cTvMPdKUrBua7aC+MJxxpEkfVbS\n90f8+DMfDM69sb3eMORk27slnSBp7xKuBl+Ynfgd5gXh+bOwRnsTVNXjCn70sb1SVavJPdJrqqra\n+34tuY+kPeH5k7ITv8NEqmq25P57XQfZII1ls9eEH/94O2QjPwDrCAYIEAwQIBggQDBAgGCAAMEA\ngZ0YzJm9B5iCtvmHJL2i6yBLZif+pX+/JNk+X9Jf5px7kqSPjD7Rcrq0vV5p+4sDzn/vmMMsi524\nzdIV2sSGdpKSDe0mr21g+JCkdPfLq6vqmhFGWgo7LphEW1B4iaQfVtXR3vMsM9vnSDo+1t5ty4Jg\ngMBO/KUf2DSCAQIEAwQIBggQDBAgGCBAMECAYIAAwQABggECBAMECAYIEAwQIBggQDBAgGCAAMEA\nAYIBAgQDBAgGCBAMECAYIEAwQIBggADBAAGCAQIEAwQIBggQDBAgGCBAMEDg3wk1m/lkRzKtAAAA\nAElFTkSuQmCC\n",
+ "text/plain": [
+ "<matplotlib.figure.Figure at 0x7fdea6fc12e8>"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "plot_trace(trace_tour(t2a))\n",
+ "t2a"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 81,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'FLRFFRLLFRFFFLFFLFFRFRRLLFFRLFFFFFLLFFRFRFL'"
+ ]
+ },
+ "execution_count": 81,
+ "metadata": {},
+ "output_type": "execute_result"
+ },
+ {
+ "data": {
+ "image/png": "iVBORw0KGgoAAAANSUhEUgAAALUAAAEACAYAAAD1IzfbAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAACLlJREFUeJzt3VvIZWUdx/HvXxsnzyMNeQQTJEJC8FChlVBgSoEU3dhd\nRndFpIREEXVhN3ph0YEgujCIbgqvSqRuCpSi0CTToNKQ1GzwMDoe5uS/i3e/ta1R1toza717fvP9\nwLD3xXp8noGvyyX74VnV3UhJjtvqBUhHmlErjlErjlErjlErjlErjlErjlErjlErjlErjlErjlEr\njlErjlErjlErjlErjlErjlErjlErjlErjlErjlErjlFrJVW1s6ou3up1HIpRa7SquhbYBTxQVT3i\nz52zrM/DbDRWVd0DXAm8BHxt4LCbgZ3Axd39x4mWBsCbpvyHK1t3nzz02qq6no2oH51uRRt8/NBc\nfg7Q3XumnsioFceoFceoFceoFceoFceoFceoFceoFceo11hVnV1V6/ir75WwsalpqxdyKEa9pqrq\nBuAJYP/ITUPvm2F5vwSeA54dMebARGv5P+t4F9CGh5a+3z3g+m3AB4GfAGdNsqLXzrWjuw+OGPMh\ngKq6sLv/Os2yNhj1muru3wI19PqqOgl4EThzskX917YVxpy3+Nx9JBdyKD5+hOjulxZf79rShby+\nHwJ0966pJzJqxTFqxTFqxTFqxTFqxTFqxTFqxTFqxTFqrWJzQ9PpW72QQzHqPC/PMMeDi8+9M8w1\nmlGHqKrNg2UumGG6JwG6+5URYy6Cje20k6xoiVHn2L74vGSGuQafzLTkmsXn9je86ggw6hDd/czi\n67puaLodoLv/PvVERq04Rq04Rq04Rq04Rq04Rq04Rq04Rq04Rq1VbG5oOnGrF3IonvuR5+qqauCe\ngdfvAc4H3j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FqxTFqxTFq\nxTFqxTFqxTFqxTFqxTFqxTFqxTFqxTFqxfk3Gpchq3+xOKsAAAAASUVORK5CYII=\n",
+ "text/plain": [
+ "<matplotlib.figure.Figure at 0x7fdea6c4e550>"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "plot_trace(trace_tour(t2b))\n",
+ "t2b"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 84,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "(94,\n",
+ " 'FFRFLLFFFRLRRFFFLFLRRFLLFFFFFRFLFFFFFRLLFRFRLLFFFFFFLRFFRLLFRFFFLFFLFFRFRRLLFFRLFFFFFLLFFRFRFL')"
+ ]
+ },
+ "execution_count": 84,
+ "metadata": {},
+ "output_type": "execute_result"
+ },
+ {
+ "data": {
+ "image/png": "iVBORw0KGgoAAAANSUhEUgAAAP4AAAEACAYAAACTecuMAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAADo5JREFUeJzt3X/sZFV5x/HPs1+oLt0VDVn4sgILSlfMgkqVttjY9Mcq\nglJJV9GUosTaKAbLP7VNSZo0TYox9o/WNqXxRzSm2taGYkzRYktUSNhKu1JpgSylZYGybEAbYXdl\nF9h9+sec0cGuzDmzc+acO8/7lXxzL8k5c57Lnc/Mnc0595q7C0Asa1oXAGDxCD4QEMEHAiL4QEAE\nHwiI4AMBEXwgIIIPBETwgYAIPhAQwQcCIvhAQAQfCIjgAwERfCAggg8ERPCBgAg+EBDBBwIi+EBA\nBB8IiOBXYmZrzMxa13G0zGylsH3xcc8wRlH7RYwxtPNN8CswszdIOiTpsJl5xt9hM/u91nX/MDP7\nc0nPZB6Dm9kulR/3rYVj7Chs/7iZ3V/Y5+sLOO6m55vg13FDYXuT9AdmtqVGMUfhytYFLKnm5/uY\nVgMvueMk7ZG00TOeWGJmn5b0LklPV65rFqe4+8O5jc1sjSTPOe6JPivufqh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XUCPupq5h2xnp+3P\nmdmrM9q/VtJZFevp2WmSZGavl/S/U9q+QNJ7qlfUAav07ANUdDQPlnD3rAdLLAszu0LSpwq77Zd0\nUk+zHOeN4AeQHghylqSv1HrKzTJIS4svkfSP7v5463pqIvhAQPzjHhAQwQcCIvhAQAQfCIjgAwER\nfCAggg8ERPCBgAg+EBDBBwIi+EBABB8IiOADARF8ICCCDwRE8IGACD4QEMEHAiL4QEAEHwiI4AMB\nEXwgIIIPBETwgYAIPhAQwQcCIvhAQAQfCIjgAwERfCAggg8E9H9g3ys8YjIz8gAAAABJRU5ErkJg\ngg==\n",
+ "text/plain": [
+ "<matplotlib.figure.Figure at 0x7fdea6e6ca20>"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "plot_trace(trace_tour(t2a + t2b))\n",
+ "len(t2a + t2b), t2a + t2b"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.5.2+"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}