From 7550a1b72dff3529dd0b32ba8859db137bc125f8 Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Tue, 13 Jun 2017 16:37:41 +0100 Subject: [PATCH] Started on brainfuck soluiton --- 02-lifts/02-lifts.txt | 3 +- 02-lifts/lifts-solution.ipynb | 248 +++++++++++++-- 02-lifts/part1-brainfuck.ipynb | 539 +++++++++++++++++++++++++++++++ 02-lifts/part1.bf | 1 + 02-lifts/part1.bf.out | 1 + 02-lifts/part2-brainfuck.ipynb | 560 +++++++++++++++++++++++++++++++++ 6 files changed, 1329 insertions(+), 23 deletions(-) create mode 100644 02-lifts/part1-brainfuck.ipynb create mode 100644 02-lifts/part1.bf create mode 100644 02-lifts/part1.bf.out create mode 100644 02-lifts/part2-brainfuck.ipynb diff --git a/02-lifts/02-lifts.txt b/02-lifts/02-lifts.txt index f591c54..f7f8113 100644 --- a/02-lifts/02-lifts.txt +++ b/02-lifts/02-lifts.txt @@ -1 +1,2 @@ -vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^=^^v^^v^vv^^v^^^=v^v^^^v=^vvv^^^^v^^^^^v^v^v^^v=^^^^^v=v^^v=^v^^=v^^vvv=^^^vv=^^=^vv^v^^^vv^v^^vvv^v=^=^=^^v^v^^=vvvv^v^vv=^^^=^^^v^v^vv^^vv^vv^^=v=v=v^=^=^^=v^^^=v^=^vvv^^vv^^=^v^vvv=v^vv^v^^^=^v^v^vv^^^^v^vv^vv^^v=v^^v^^^^vv=vv^v=^^=vv=^v^v^^^^^vv^v=^=^^vvv^v^vvvvv^^vv^v^v^^v^=^v^^^^vvvv=^=vv^^^^^^^^v^vv^^^^v^^^v^^^v^^v^vv^^^^=vv=^v^^^vvvv^v^vvv^v^=^=v^^^^^=vvv^vvvvv^^vv^^vv^vvv^^^=v^=^=^v^^^=v=^^vvv^v^^^v=^^^=^^vv=v^^^^^^^vv^v^vv=v^^^vv=v^v^=^v^^=^^v^v^v^v^^v=v^^vvv^^v^^v^v=vvv^v^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v^vv^^^^^=vv=^v=vv^v=^v^^= + diff --git a/02-lifts/lifts-solution.ipynb b/02-lifts/lifts-solution.ipynb index 281eb44..bf60b78 100644 --- a/02-lifts/lifts-solution.ipynb +++ b/02-lifts/lifts-solution.ipynb @@ -34,7 +34,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "metadata": { "collapsed": true }, @@ -51,7 +51,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "metadata": { "collapsed": true }, @@ -66,7 +66,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -75,7 +75,7 @@ "209" ] }, - "execution_count": 3, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } @@ -89,7 +89,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 5, "metadata": { "collapsed": true }, @@ -106,16 +106,16 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "(10000, 216, -6)" + "(10002, 216, -6)" ] }, - "execution_count": 16, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -136,7 +136,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -145,7 +145,7 @@ "209" ] }, - "execution_count": 4, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -168,7 +168,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "metadata": { "collapsed": true }, @@ -187,7 +187,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -196,7 +196,7 @@ "215" ] }, - "execution_count": 8, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -207,7 +207,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -216,7 +216,7 @@ "-5" ] }, - "execution_count": 17, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -227,7 +227,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -236,7 +236,7 @@ "209" ] }, - "execution_count": 18, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -247,7 +247,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -256,7 +256,7 @@ "-2" ] }, - "execution_count": 19, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -267,16 +267,16 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "1257" + "1259" ] }, - "execution_count": 21, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -285,6 +285,210 @@ "len(exits(instructions))" ] }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Counter({-5: 1,\n", + " -4: 1,\n", + " -2: 2,\n", + " 1: 1,\n", + " 3: 1,\n", + " 6: 1,\n", + " 11: 1,\n", + " 12: 1,\n", + " 18: 1,\n", + " 19: 2,\n", + " 20: 3,\n", + " 21: 3,\n", + " 22: 4,\n", + " 23: 4,\n", + " 24: 6,\n", + " 25: 4,\n", + " 26: 4,\n", + " 27: 6,\n", + " 28: 4,\n", + " 29: 4,\n", + " 30: 2,\n", + " 31: 1,\n", + " 32: 7,\n", + " 33: 3,\n", + " 34: 5,\n", + " 35: 2,\n", + " 36: 2,\n", + " 37: 2,\n", + " 38: 3,\n", + " 39: 5,\n", + " 40: 9,\n", + " 41: 4,\n", + " 42: 7,\n", + " 43: 11,\n", + " 44: 15,\n", + " 45: 19,\n", + " 46: 22,\n", + " 47: 12,\n", + " 48: 23,\n", + " 49: 24,\n", + " 50: 27,\n", + " 51: 25,\n", + " 52: 27,\n", + " 53: 25,\n", + " 54: 16,\n", + " 55: 21,\n", + " 56: 21,\n", + " 57: 15,\n", + " 58: 13,\n", + " 59: 18,\n", + " 60: 19,\n", + " 61: 13,\n", + " 62: 21,\n", + " 63: 15,\n", + " 64: 19,\n", + " 65: 18,\n", + " 66: 17,\n", + " 67: 17,\n", + " 68: 8,\n", + " 69: 8,\n", + " 70: 12,\n", + " 71: 6,\n", + " 72: 5,\n", + " 73: 3,\n", + " 74: 6,\n", + " 75: 5,\n", + " 76: 3,\n", + " 77: 2,\n", + " 78: 1,\n", + " 79: 4,\n", + " 80: 2,\n", + " 81: 1,\n", + " 83: 1,\n", + " 84: 4,\n", + " 87: 3,\n", + " 88: 4,\n", + " 89: 2,\n", + " 90: 2,\n", + " 91: 3,\n", + " 92: 1,\n", + " 93: 5,\n", + " 94: 2,\n", + " 95: 6,\n", + " 96: 5,\n", + " 97: 11,\n", + " 98: 10,\n", + " 99: 15,\n", + " 100: 10,\n", + " 101: 17,\n", + " 102: 15,\n", + " 103: 6,\n", + " 104: 9,\n", + " 105: 6,\n", + " 106: 8,\n", + " 107: 13,\n", + " 108: 12,\n", + " 109: 9,\n", + " 110: 10,\n", + " 111: 7,\n", + " 112: 4,\n", + " 113: 8,\n", + " 114: 13,\n", + " 115: 6,\n", + " 116: 6,\n", + " 117: 6,\n", + " 118: 6,\n", + " 119: 7,\n", + " 120: 4,\n", + " 121: 3,\n", + " 122: 5,\n", + " 123: 8,\n", + " 124: 6,\n", + " 125: 7,\n", + " 126: 6,\n", + " 127: 4,\n", + " 128: 3,\n", + " 129: 5,\n", + " 130: 6,\n", + " 131: 6,\n", + " 132: 8,\n", + " 133: 5,\n", + " 134: 13,\n", + " 135: 13,\n", + " 136: 14,\n", + " 137: 9,\n", + " 138: 16,\n", + " 139: 12,\n", + " 140: 12,\n", + " 141: 11,\n", + " 142: 15,\n", + " 143: 16,\n", + " 144: 3,\n", + " 145: 5,\n", + " 146: 10,\n", + " 147: 3,\n", + " 148: 3,\n", + " 149: 2,\n", + " 150: 3,\n", + " 151: 6,\n", + " 152: 7,\n", + " 153: 5,\n", + " 154: 7,\n", + " 155: 5,\n", + " 156: 5,\n", + " 157: 1,\n", + " 158: 5,\n", + " 159: 5,\n", + " 160: 6,\n", + " 161: 2,\n", + " 162: 2,\n", + " 164: 7,\n", + " 165: 2,\n", + " 166: 2,\n", + " 167: 3,\n", + " 168: 1,\n", + " 169: 4,\n", + " 170: 3,\n", + " 171: 1,\n", + " 173: 1,\n", + " 178: 1,\n", + " 179: 1,\n", + " 181: 1,\n", + " 185: 1,\n", + " 187: 1,\n", + " 188: 1,\n", + " 189: 1,\n", + " 192: 2,\n", + " 193: 1,\n", + " 194: 3,\n", + " 195: 1,\n", + " 196: 2,\n", + " 199: 1,\n", + " 200: 2,\n", + " 201: 1,\n", + " 204: 1,\n", + " 205: 1,\n", + " 207: 2,\n", + " 208: 3,\n", + " 209: 11,\n", + " 210: 2,\n", + " 211: 1,\n", + " 212: 1,\n", + " 213: 2,\n", + " 215: 2})" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import collections\n", + "collections.Counter(exits(instructions))" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/02-lifts/part1-brainfuck.ipynb b/02-lifts/part1-brainfuck.ipynb new file mode 100644 index 0000000..bc880de --- /dev/null +++ b/02-lifts/part1-brainfuck.ipynb @@ -0,0 +1,539 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 121, + "metadata": {}, + "outputs": [], + "source": [ + "#!/usr/bin/python\n", + "#\n", + "# Brainfuck Interpreter\n", + "# Copyright 2011 Sebastian Kaspari\n", + "#\n", + "# Usage: ./brainfuck.py [FILE]\n", + "\n", + "import sys\n", + "\n", + "def execute(filename):\n", + " f = open(filename, \"r\")\n", + " evaluate(f.read())\n", + " f.close()\n", + "\n", + "\n", + "def evaluate(code, inp=None, debug=False):\n", + " code = cleanup(list(code))\n", + " bracemap = buildbracemap(code)\n", + "\n", + " cells, codeptr, cellptr = [0], 0, 0\n", + " inputptr = 0\n", + "\n", + " try:\n", + " while codeptr < len(code):\n", + " command = code[codeptr]\n", + " \n", + " if debug:\n", + " print(command, cellptr, cells)\n", + "\n", + " if command == \">\":\n", + " cellptr += 1\n", + " if cellptr == len(cells): cells.append(0)\n", + "\n", + " if command == \"<\":\n", + " cellptr = 0 if cellptr <= 0 else cellptr - 1\n", + "\n", + " if command == \"+\":\n", + " cells[cellptr] = cells[cellptr] + 1 if cells[cellptr] < 255 else 0\n", + "\n", + " if command == \"-\":\n", + " cells[cellptr] = cells[cellptr] - 1 if cells[cellptr] > 0 else 255\n", + "\n", + " if command == \"[\" and cells[cellptr] == 0: codeptr = bracemap[codeptr]\n", + " if command == \"]\" and cells[cellptr] != 0: codeptr = bracemap[codeptr]\n", + " if command == \".\": sys.stdout.write(chr(cells[cellptr]))\n", + " if command == \",\": \n", + " if inp is not None:\n", + " if inputptr >= len(inp):\n", + " raise EOFError\n", + " cells[cellptr] = ord(inp[inputptr])\n", + " inputptr += 1\n", + " else:\n", + " cells[cellptr] = ord(getch.getch())\n", + "\n", + " codeptr += 1\n", + " except EOFError:\n", + " pass\n", + " return cells, codeptr, cellptr\n", + "\n", + "\n", + "def cleanup(code):\n", + " return list(filter(lambda x: x in ['.', ',', '[', ']', '<', '>', '+', '-'], code))\n", + "\n", + "\n", + "def buildbracemap(code):\n", + " temp_bracestack, bracemap = [], {}\n", + "\n", + " for position, command in enumerate(code):\n", + " if command == \"[\": temp_bracestack.append(position)\n", + " if command == \"]\":\n", + " start = temp_bracestack.pop()\n", + " bracemap[start] = position\n", + " bracemap[position] = start\n", + " return bracemap\n", + "\n", + "\n", + "# def main():\n", + "# if len(sys.argv) == 2: execute(sys.argv[1])\n", + "# else: print(\"Usage:\", sys.argv[0], \"filename\")\n", + "\n", + "# if __name__ == \"__main__\": main()\n" + ] + }, + { + "cell_type": "code", + "execution_count": 128, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(118, 94, 61)" + ] + }, + "execution_count": 128, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ord('v'), ord('^'), ord('=')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "```\n", + "set cell 1 to 94\n", + "set cell 2 to 118-94=24\n", + "copy cell 1 into cell 0, using cell 3\n", + "\n", + "set cell 5 to 0\n", + "read character into cell 6\n", + "while cell 6 != 0\n", + " subtract cell 0 from cell 6\n", + " if cell 6 == 0\n", + " increment cell 5\n", + " else\n", + " copy cell 2 into cell 0, using cell 3\n", + " subtract cell 0 from cell 6\n", + " if cell 6 == 0\n", + " decrement cell 5\n", + " read character into cell 6\n", + "output cell 3\n", + "```\n" + ] + }, + { + "cell_type": "code", + "execution_count": 129, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "24" + ] + }, + "execution_count": 129, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "118-94" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "helloworld= '++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.'" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Hello World!\n" + ] + }, + { + "data": { + "text/plain": [ + "([0, 0, 72, 100, 87, 33, 10], 106, 6)" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "evaluate(helloworld)" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "hello" + ] + }, + { + "data": { + "text/plain": [ + "([111], 3, 0)" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "evaluate(',[.,]', input='hello')" + ] + }, + { + "cell_type": "code", + "execution_count": 196, + "metadata": {}, + "outputs": [], + "source": [ + "program = '>' + '+' * 94 + '>' + '+' * 24\n", + "program += \"\"\"\n", + "copy cell 1 into cell 0 using cell 3\n", + "\n", + "<\n", + "[-<+>>>+<<]\n", + "\n", + ">>\n", + "[-<<+>>]\n", + "\n", + "read into cell 5\n", + ">>,\n", + "\n", + "[\n", + " subtract cell 0 from cell 5\n", + " <<<<<[->>>>>-<<<<<]\n", + " >>>>>\n", + "\n", + " if cell 5 != 0 do more\n", + " [\n", + "\n", + " copy cell 2 into cell 0 using cell 3\n", + " <<<[->+<<<+>>]\n", + "\n", + " move cell 3 into cell 2\n", + " >[-<+>]\n", + " <\n", + "\n", + " subtract cell 0 from cell 5\n", + " <<[->>>>>-<<<<<]\n", + " >>>>>\n", + "\n", + " if cell 5 != 0\n", + " [\n", + " increment cell 4 by 1\n", + " <+>\n", + "\n", + " clear cell 5 to stop the loop\n", + " [-]\n", + " ]\n", + " decrement cell 4 by 2\n", + " <-->\n", + "\n", + " ]\n", + "\n", + " increment cell 4 by 1\n", + " <+\n", + "\n", + " copy cell 1 into cell 0 using cell 3\n", + " <<<[-<+>>>+<<]\n", + "\n", + " move cell 3 into cell 1\n", + " >>[-<<+>>]\n", + "\n", + " >>\n", + "\n", + " read next input\n", + " ,\n", + "]\n", + "write the output\n", + "<.\n", + "\n", + "\"\"\"" + ] + }, + { + "cell_type": "code", + "execution_count": 197, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "([94, 94, 24, 0, 3, 0], 255, 5)" + ] + }, + "execution_count": 197, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "evaluate(program, inp='^^v=^^^v')" + ] + }, + { + "cell_type": "code", + "execution_count": 198, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++<[-<+>>>+<<]>>[-<<+>>]>>,[<<<<<[->>>>>-<<<<<]>>>>>[<<<[->+<<<+>>]>[-<+>]<<<[->>>>>-<<<<<]>>>>>[<+>[-]]<-->]<+<<<[-<+>>>+<<]>>[-<<+>>]>>,]<.'" + ] + }, + "execution_count": 198, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "''.join(cleanup(program))" + ] + }, + { + "cell_type": "code", + "execution_count": 123, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "([60, 60, 0, 15, 0], 152, 4)" + ] + }, + "execution_count": 123, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "inp = open('02-lifts.txt').read().strip()\n", + "evaluate(program, inp=inp)" + ] + }, + { + "cell_type": "code", + "execution_count": 124, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def value(instr):\n", + " if instr == '^':\n", + " return 1\n", + " elif instr == 'v':\n", + " return -1\n", + " else:\n", + " return 0" + ] + }, + { + "cell_type": "code", + "execution_count": 125, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def final(sequence):\n", + " current = 0\n", + " for c in sequence:\n", + " current += value(c)\n", + " return current" + ] + }, + { + "cell_type": "code", + "execution_count": 126, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "209" + ] + }, + "execution_count": 126, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "final(inp)" + ] + }, + { + "cell_type": "code", + "execution_count": 193, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0 ([94, 94, 24, 0, 0, 0], 144, 5) \n", + "-1 ([94, 94, 24, 0, 255, 0], 255, 5) v\n", + "-2 ([94, 94, 24, 0, 254, 0], 255, 5) vv\n", + "-3 ([94, 94, 24, 0, 253, 0], 255, 5) vvv\n", + "-2 ([94, 94, 24, 0, 254, 0], 255, 5) vvv^\n", + "-1 ([94, 94, 24, 0, 255, 0], 255, 5) vvv^^\n", + "-2 ([94, 94, 24, 0, 254, 0], 255, 5) vvv^^v\n", + "-1 ([94, 94, 24, 0, 255, 0], 255, 5) vvv^^v^\n", + "-2 ([94, 94, 24, 0, 254, 0], 255, 5) vvv^^v^v\n", + "-2 ([94, 94, 24, 0, 254, 0], 255, 5) vvv^^v^v=\n", + "-3 ([94, 94, 24, 0, 253, 0], 255, 5) vvv^^v^v=v\n", + "-4 ([94, 94, 24, 0, 252, 0], 255, 5) vvv^^v^v=vv\n", + "-3 ([94, 94, 24, 0, 253, 0], 255, 5) vvv^^v^v=vv^\n", + "-4 ([94, 94, 24, 0, 252, 0], 255, 5) vvv^^v^v=vv^v\n", + "-3 ([94, 94, 24, 0, 253, 0], 255, 5) vvv^^v^v=vv^v^\n", + "-2 ([94, 94, 24, 0, 254, 0], 255, 5) vvv^^v^v=vv^v^^\n", + "-3 ([94, 94, 24, 0, 253, 0], 255, 5) vvv^^v^v=vv^v^^v\n", + "-4 ([94, 94, 24, 0, 252, 0], 255, 5) vvv^^v^v=vv^v^^vv\n", + "-5 ([94, 94, 24, 0, 251, 0], 255, 5) vvv^^v^v=vv^v^^vvv\n", + "-6 ([94, 94, 24, 0, 250, 0], 255, 5) vvv^^v^v=vv^v^^vvvv\n", + "-5 ([94, 94, 24, 0, 251, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^\n", + "-4 ([94, 94, 24, 0, 252, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^\n", + "-5 ([94, 94, 24, 0, 251, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v\n", + "-5 ([94, 94, 24, 0, 251, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=\n", + "-4 ([94, 94, 24, 0, 252, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^\n", + "-4 ([94, 94, 24, 0, 252, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=\n", + "-3 ([94, 94, 24, 0, 253, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^\n", + "-2 ([94, 94, 24, 0, 254, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^\n", + "-2 ([94, 94, 24, 0, 254, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=\n", + "-1 ([94, 94, 24, 0, 255, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^\n", + "0 ([94, 94, 24, 0, 0, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^\n", + "1 ([94, 94, 24, 0, 1, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^\n", + "1 ([94, 94, 24, 0, 1, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=\n", + "2 ([94, 94, 24, 0, 2, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^\n", + "3 ([94, 94, 24, 0, 3, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^\n", + "4 ([94, 94, 24, 0, 4, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^\n", + "3 ([94, 94, 24, 0, 3, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v\n", + "3 ([94, 94, 24, 0, 3, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=\n", + "4 ([94, 94, 24, 0, 4, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^\n", + "5 ([94, 94, 24, 0, 5, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^\n", + "6 ([94, 94, 24, 0, 6, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^\n", + "6 ([94, 94, 24, 0, 6, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^=\n", + "7 ([94, 94, 24, 0, 7, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^=^\n", + "8 ([94, 94, 24, 0, 8, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^=^^\n", + "7 ([94, 94, 24, 0, 7, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^=^^v\n", + "8 ([94, 94, 24, 0, 8, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^=^^v^\n", + "9 ([94, 94, 24, 0, 9, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^=^^v^^\n", + "8 ([94, 94, 24, 0, 8, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^=^^v^^v\n", + "9 ([94, 94, 24, 0, 9, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^=^^v^^v^\n", + "8 ([94, 94, 24, 0, 8, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^=^^v^^v^v\n" + ] + } + ], + "source": [ + "for i in range(50):\n", + " print(final(inp[:i]), evaluate(program, inp[:i]), inp[:i])" + ] + }, + { + "cell_type": "code", + "execution_count": 194, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "(209, ([94, 94, 24, 0, 209, 0], 255, 5))" + ] + }, + "execution_count": 194, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "final(inp), evaluate(program, inp)" + ] + }, + { + "cell_type": "code", + "execution_count": 199, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "! bf -n part1.bf < 02-lifts.txt > part1.bf.out" + ] + }, + { + "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 +} diff --git a/02-lifts/part1.bf b/02-lifts/part1.bf new file mode 100644 index 0000000..2199595 --- /dev/null +++ b/02-lifts/part1.bf @@ -0,0 +1 @@ +>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++<[-<+>>>+<<]>>[-<<+>>]>>,[<<<<<[->>>>>-<<<<<]>>>>>[<<<[->+<<<+>>]>[-<+>]<<<[->>>>>-<<<<<]>>>>>[<+>[-]]<-->]<+<<<[-<+>>>+<<]>>[-<<+>>]>>,]<. diff --git a/02-lifts/part1.bf.out b/02-lifts/part1.bf.out new file mode 100644 index 0000000..2b8e128 --- /dev/null +++ b/02-lifts/part1.bf.out @@ -0,0 +1 @@ +Ñ \ No newline at end of file diff --git a/02-lifts/part2-brainfuck.ipynb b/02-lifts/part2-brainfuck.ipynb new file mode 100644 index 0000000..d43ab27 --- /dev/null +++ b/02-lifts/part2-brainfuck.ipynb @@ -0,0 +1,560 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 121, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "#!/usr/bin/python\n", + "#\n", + "# Brainfuck Interpreter\n", + "# Copyright 2011 Sebastian Kaspari\n", + "#\n", + "# Usage: ./brainfuck.py [FILE]\n", + "\n", + "import sys\n", + "\n", + "def execute(filename):\n", + " f = open(filename, \"r\")\n", + " evaluate(f.read())\n", + " f.close()\n", + "\n", + "\n", + "def evaluate(code, inp=None, debug=False):\n", + " code = cleanup(list(code))\n", + " bracemap = buildbracemap(code)\n", + "\n", + " cells, codeptr, cellptr = [0], 0, 0\n", + " inputptr = 0\n", + "\n", + " try:\n", + " while codeptr < len(code):\n", + " command = code[codeptr]\n", + " \n", + " if debug:\n", + " print(command, cellptr, cells)\n", + "\n", + " if command == \">\":\n", + " cellptr += 1\n", + " if cellptr == len(cells): cells.append(0)\n", + "\n", + " if command == \"<\":\n", + " cellptr = 0 if cellptr <= 0 else cellptr - 1\n", + "\n", + " if command == \"+\":\n", + " cells[cellptr] = cells[cellptr] + 1 if cells[cellptr] < 255 else 0\n", + "\n", + " if command == \"-\":\n", + " cells[cellptr] = cells[cellptr] - 1 if cells[cellptr] > 0 else 255\n", + "\n", + " if command == \"[\" and cells[cellptr] == 0: codeptr = bracemap[codeptr]\n", + " if command == \"]\" and cells[cellptr] != 0: codeptr = bracemap[codeptr]\n", + " if command == \".\": sys.stdout.write(chr(cells[cellptr]))\n", + " if command == \",\": \n", + " if inp is not None:\n", + " if inputptr >= len(inp):\n", + " raise EOFError\n", + " cells[cellptr] = ord(inp[inputptr])\n", + " inputptr += 1\n", + " else:\n", + " cells[cellptr] = ord(getch.getch())\n", + "\n", + " codeptr += 1\n", + " except EOFError:\n", + " pass\n", + " return cells, codeptr, cellptr\n", + "\n", + "\n", + "def cleanup(code):\n", + " return list(filter(lambda x: x in ['.', ',', '[', ']', '<', '>', '+', '-'], code))\n", + "\n", + "\n", + "def buildbracemap(code):\n", + " temp_bracestack, bracemap = [], {}\n", + "\n", + " for position, command in enumerate(code):\n", + " if command == \"[\": temp_bracestack.append(position)\n", + " if command == \"]\":\n", + " start = temp_bracestack.pop()\n", + " bracemap[start] = position\n", + " bracemap[position] = start\n", + " return bracemap\n", + "\n", + "\n", + "# def main():\n", + "# if len(sys.argv) == 2: execute(sys.argv[1])\n", + "# else: print(\"Usage:\", sys.argv[0], \"filename\")\n", + "\n", + "# if __name__ == \"__main__\": main()\n" + ] + }, + { + "cell_type": "code", + "execution_count": 128, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(118, 94, 61)" + ] + }, + "execution_count": 128, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ord('v'), ord('^'), ord('=')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "```\n", + "set cell 1 to 61\n", + "set cell 2 to 94-61=33\n", + "set cell 3 to 118-94=24\n", + "copy cell 1 into cell 0, using cell 4\n", + "\n", + "set cell 6 to 0 (current level)\n", + "set cell 7 to 0 (highest exit)\n", + "reserve cell 8 for scratch\n", + "\n", + "read character into cell 9\n", + "while cell 9 != 0\n", + " subtract cell 0 from cell 9\n", + " if cell 9 == 0 we're at an exit\n", + " if cell 6 is higher then cell 7\n", + " copy cell 6 into cell 7\n", + " else\n", + " subtract cell 2 from cell 9\n", + " if cell 9 == 0 we're going up\n", + " increment cell 6\n", + " else\n", + " decrement cell 6\n", + " \n", + " copy cell 1 into cell 0 using cell 4\n", + " read character into cell 6\n", + " \n", + "output cell 7\n", + "```\n", + "\n", + "```\n", + "Hold highest exit in unary, as seq 10, 9, 8... 1, 0.\n", + "When get a new exit, set level in leftmost cell, rebuild the sequence.\n", + "If when you get to the end, there's a non-zero cell to the right, it wasn't longest.\n", + " move to the right until you reach zero, then rebuild the longest sequence right-to-left\n", + " when to stop?\n", + "```\n" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "118" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "61+33+24" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "helloworld= '++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.'" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Hello World!\n" + ] + }, + { + "data": { + "text/plain": [ + "([0, 0, 72, 100, 87, 33, 10], 106, 6)" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "evaluate(helloworld)" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "hello" + ] + }, + { + "data": { + "text/plain": [ + "([111], 3, 0)" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "evaluate(',[.,]', input='hello')" + ] + }, + { + "cell_type": "code", + "execution_count": 196, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "program = '>' + '+' * 94 + '>' + '+' * 24\n", + "program += \"\"\"\n", + "copy cell 1 into cell 0 using cell 3\n", + "\n", + "<\n", + "[-<+>>>+<<]\n", + "\n", + ">>\n", + "[-<<+>>]\n", + "\n", + "read into cell 5\n", + ">>,\n", + "\n", + "[\n", + " subtract cell 0 from cell 5\n", + " <<<<<[->>>>>-<<<<<]\n", + " >>>>>\n", + "\n", + " if cell 5 != 0 do more\n", + " [\n", + "\n", + " copy cell 2 into cell 0 using cell 3\n", + " <<<[->+<<<+>>]\n", + "\n", + " move cell 3 into cell 2\n", + " >[-<+>]\n", + " <\n", + "\n", + " subtract cell 0 from cell 5\n", + " <<[->>>>>-<<<<<]\n", + " >>>>>\n", + "\n", + " if cell 5 != 0\n", + " [\n", + " increment cell 4 by 1\n", + " <+>\n", + "\n", + " clear cell 5 to stop the loop\n", + " [-]\n", + " ]\n", + " decrement cell 4 by 2\n", + " <-->\n", + "\n", + " ]\n", + "\n", + " increment cell 4 by 1\n", + " <+\n", + "\n", + " copy cell 1 into cell 0 using cell 3\n", + " <<<[-<+>>>+<<]\n", + "\n", + " move cell 3 into cell 1\n", + " >>[-<<+>>]\n", + "\n", + " >>\n", + "\n", + " read next input\n", + " ,\n", + "]\n", + "write the output\n", + "<.\n", + "\n", + "\"\"\"" + ] + }, + { + "cell_type": "code", + "execution_count": 197, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "([94, 94, 24, 0, 3, 0], 255, 5)" + ] + }, + "execution_count": 197, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "evaluate(program, inp='^^v=^^^v')" + ] + }, + { + "cell_type": "code", + "execution_count": 198, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++<[-<+>>>+<<]>>[-<<+>>]>>,[<<<<<[->>>>>-<<<<<]>>>>>[<<<[->+<<<+>>]>[-<+>]<<<[->>>>>-<<<<<]>>>>>[<+>[-]]<-->]<+<<<[-<+>>>+<<]>>[-<<+>>]>>,]<.'" + ] + }, + "execution_count": 198, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "''.join(cleanup(program))" + ] + }, + { + "cell_type": "code", + "execution_count": 123, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "([60, 60, 0, 15, 0], 152, 4)" + ] + }, + "execution_count": 123, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "inp = open('02-lifts.txt').read().strip()\n", + "evaluate(program, inp=inp)" + ] + }, + { + "cell_type": "code", + "execution_count": 124, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def value(instr):\n", + " if instr == '^':\n", + " return 1\n", + " elif instr == 'v':\n", + " return -1\n", + " else:\n", + " return 0" + ] + }, + { + "cell_type": "code", + "execution_count": 125, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def final(sequence):\n", + " current = 0\n", + " for c in sequence:\n", + " current += value(c)\n", + " return current" + ] + }, + { + "cell_type": "code", + "execution_count": 126, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "209" + ] + }, + "execution_count": 126, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "final(inp)" + ] + }, + { + "cell_type": "code", + "execution_count": 193, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0 ([94, 94, 24, 0, 0, 0], 144, 5) \n", + "-1 ([94, 94, 24, 0, 255, 0], 255, 5) v\n", + "-2 ([94, 94, 24, 0, 254, 0], 255, 5) vv\n", + "-3 ([94, 94, 24, 0, 253, 0], 255, 5) vvv\n", + "-2 ([94, 94, 24, 0, 254, 0], 255, 5) vvv^\n", + "-1 ([94, 94, 24, 0, 255, 0], 255, 5) vvv^^\n", + "-2 ([94, 94, 24, 0, 254, 0], 255, 5) vvv^^v\n", + "-1 ([94, 94, 24, 0, 255, 0], 255, 5) vvv^^v^\n", + "-2 ([94, 94, 24, 0, 254, 0], 255, 5) vvv^^v^v\n", + "-2 ([94, 94, 24, 0, 254, 0], 255, 5) vvv^^v^v=\n", + "-3 ([94, 94, 24, 0, 253, 0], 255, 5) vvv^^v^v=v\n", + "-4 ([94, 94, 24, 0, 252, 0], 255, 5) vvv^^v^v=vv\n", + "-3 ([94, 94, 24, 0, 253, 0], 255, 5) vvv^^v^v=vv^\n", + "-4 ([94, 94, 24, 0, 252, 0], 255, 5) vvv^^v^v=vv^v\n", + "-3 ([94, 94, 24, 0, 253, 0], 255, 5) vvv^^v^v=vv^v^\n", + "-2 ([94, 94, 24, 0, 254, 0], 255, 5) vvv^^v^v=vv^v^^\n", + "-3 ([94, 94, 24, 0, 253, 0], 255, 5) vvv^^v^v=vv^v^^v\n", + "-4 ([94, 94, 24, 0, 252, 0], 255, 5) vvv^^v^v=vv^v^^vv\n", + "-5 ([94, 94, 24, 0, 251, 0], 255, 5) vvv^^v^v=vv^v^^vvv\n", + "-6 ([94, 94, 24, 0, 250, 0], 255, 5) vvv^^v^v=vv^v^^vvvv\n", + "-5 ([94, 94, 24, 0, 251, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^\n", + "-4 ([94, 94, 24, 0, 252, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^\n", + "-5 ([94, 94, 24, 0, 251, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v\n", + "-5 ([94, 94, 24, 0, 251, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=\n", + "-4 ([94, 94, 24, 0, 252, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^\n", + "-4 ([94, 94, 24, 0, 252, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=\n", + "-3 ([94, 94, 24, 0, 253, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^\n", + "-2 ([94, 94, 24, 0, 254, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^\n", + "-2 ([94, 94, 24, 0, 254, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=\n", + "-1 ([94, 94, 24, 0, 255, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^\n", + "0 ([94, 94, 24, 0, 0, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^\n", + "1 ([94, 94, 24, 0, 1, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^\n", + "1 ([94, 94, 24, 0, 1, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=\n", + "2 ([94, 94, 24, 0, 2, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^\n", + "3 ([94, 94, 24, 0, 3, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^\n", + "4 ([94, 94, 24, 0, 4, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^\n", + "3 ([94, 94, 24, 0, 3, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v\n", + "3 ([94, 94, 24, 0, 3, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=\n", + "4 ([94, 94, 24, 0, 4, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^\n", + "5 ([94, 94, 24, 0, 5, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^\n", + "6 ([94, 94, 24, 0, 6, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^\n", + "6 ([94, 94, 24, 0, 6, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^=\n", + "7 ([94, 94, 24, 0, 7, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^=^\n", + "8 ([94, 94, 24, 0, 8, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^=^^\n", + "7 ([94, 94, 24, 0, 7, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^=^^v\n", + "8 ([94, 94, 24, 0, 8, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^=^^v^\n", + "9 ([94, 94, 24, 0, 9, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^=^^v^^\n", + "8 ([94, 94, 24, 0, 8, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^=^^v^^v\n", + "9 ([94, 94, 24, 0, 9, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^=^^v^^v^\n", + "8 ([94, 94, 24, 0, 8, 0], 255, 5) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^=^^v^^v^v\n" + ] + } + ], + "source": [ + "for i in range(50):\n", + " print(final(inp[:i]), evaluate(program, inp[:i]), inp[:i])" + ] + }, + { + "cell_type": "code", + "execution_count": 194, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "(209, ([94, 94, 24, 0, 209, 0], 255, 5))" + ] + }, + "execution_count": 194, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "final(inp), evaluate(program, inp)" + ] + }, + { + "cell_type": "code", + "execution_count": 199, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "! bf -n part1.bf < 02-lifts.txt > part1.bf.out" + ] + }, + { + "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 +} -- 2.34.1