From 35334be6542c54514e0a1bf11d247063c2c1ed51 Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Sun, 16 Jul 2017 19:10:39 +0100 Subject: [PATCH] Tidying up day 2 polyglot --- 02-lifts/bf-meme.jpg | Bin 0 -> 40212 bytes 02-lifts/bf.out | 0 02-lifts/bf2.py | 309 ++++++++++++++++ 02-lifts/lifts-solution.ipynb | 64 ++-- 02-lifts/part1-brainfuck.ipynb | 253 +++++++------ 02-lifts/part1.clean.bf | 1 + 02-lifts/part2-brainfuck.ipynb | 640 +++++++++++++++++++++++++-------- 02-lifts/part2.bf | 218 +++++++++++ 02-lifts/part2.bf.out | 1 + 02-lifts/part2.clean.bf | 1 + 10 files changed, 1216 insertions(+), 271 deletions(-) create mode 100644 02-lifts/bf-meme.jpg create mode 100644 02-lifts/bf.out create mode 100644 02-lifts/bf2.py create mode 100644 02-lifts/part1.clean.bf create mode 100644 02-lifts/part2.bf create mode 100644 02-lifts/part2.bf.out create mode 100644 02-lifts/part2.clean.bf diff --git a/02-lifts/bf-meme.jpg b/02-lifts/bf-meme.jpg new file mode 100644 index 0000000000000000000000000000000000000000..5f3ebea34f7026a8cda3a318074641ea8bc94c0d GIT binary patch literal 40212 zcmb6AbyOV96F&+sZXq}X3-0dj!QELjxI2pn0t5-}?(VX<2X}(|;<`wJ6ZGZz{_c6t zz4yOceP*Vod#0wVx~D%=Q`K)PZ`%M&1sQo601ONO0P~&zZ|eXl037Up^xq!to!}AS z|085XLWK>iXWE2$C4;UX%(LSP~prB)+f5gDV#KJ`VfQ^HViSwSv{ErFDe|N&c zBfsB>iH3sqUi$x$-ueMp$S~hvZs1@j0kBvwa9A*Jg8)(h0DuJZUvvNe1Op2PkAR4T zjPhPh1OtGD`+wHL1K0AG2t-ZB`xJ$=$t0D9&=gOl@|Yq{9b|^Nw}8l zv=I%NJycUD0|4Xz?r=_OnByW90-^pgxwmaeQ#W%$=$?P0oUMKGIxhb{dO3uQ7A@v# zA1{pFxf|*3oubtHbeJYq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hrr3RwbQA};LI|IS+a`(DO?i+=iFuj;>NvHDatLb z{Gs;Lj2CpTUKCe^cImp4Wh)_jAZQzGm?zqc6+Z86j;kHg9i?ut#hl2&ixVrDvIdzX zXja1(Ejc3je=IiYHW6hq%{T*Q0|{(2OaB1zpYvm|sP7r%PhB_ua8{u*5M`Dcmas^= zJyV3Sa~Oi(bcnW_Rh1199%lRLjAb&w9Eb#!O&r>y!WV|vhg6uwQ*5f_0O+$V_@3l(NP$ym1(<`ZJR;Ot7>X~bkNLA2dR+XhpUZxQXz@yQhz z9Yoo*;q$x;puXmIa~@+e0mF8svu|)ZV$r$GP7}EMg1fQse&rR<-149l{gWPk' + '+' * 33 + '>' + '+' * 24 +program += """ + + +read character into cell 9 +>>>>>>, + + + +while cell 9 != 0 # have an input +[ + set cell 10 to 1 + >[-]+ + + # clear cells 4 and 0 + <<<<<<[-]<<<<[-]> + # copy cell 1 to cell 0 using cell 4 + [-<+>>>>+<<<] + >>>[-<<<+>>>] + <<<< + + subtract cell 0 from cell 9 + [->>>>>>>>>-<<<<<<<<<] + >>>>>>>>> + + while cell 9 != 0 # we're not at an exit + [ + set cell 10 to 0 + >[-] + + copy cell 2 to cell 0 using cell 4 + <<<<<<<<[-<<+>>>>+<<] + >>[-<<+>>] + <<<< + + subtract cell 0 from cell 9 + [->>>>>>>>>-<<<<<<<<<] + >>>>> + + set cell 5 to 1 + [-]+ + >>>> + + + while cell 9 != 0 # we're going down + [ + clear cell 5 + <<<<[-] + copy cell 7 to cell 11 using cell 12 + >>[->>>>+>+<<<<<] + >>>>>[-<<<<<+>>>>>] + + cell 12 is zero + + while cell 11 != 0 # above ground + < + [ + set cell 12 to 1 + >[-]+ + + clear cell 11 + <[-] + end + ] 11 + + while cell 12 != 0 + > + [ + decrement cell 7 + <<<<<- + + set cell 12 to zero + >>>>>[-] + end + ] 12 + + <<<<<< + decrement cell 6 + - + + have now dealt with the input so clear cell 9 + >>>[-] + end + ] 9 + + + while cell 5 != 0 # we're going up + <<<< + [ + clear cell 5 + [-] + + + # set cell 12 to 0 + >>>>>>>[-] + + ### if 6 == 0 or 7 != 0 + ### set cell 12 to 1 + + # copy cell 6 to cell 11 using cell 12 + <<<<<<[->>>>>+>+<<<<<<] + >>>>>>[-<<<<<<+>>>>>>] + + set cell 12 to 1 + [-]+ + + while cell 11 != 0 + < + [ + clear cell 12 + >[-] + + set cell 11 to 0 + <[-] + end 11 + ] 11 + + + + # copy cell 7 to cell 11 using cell 13 + <<<<[->>>>+>>+<<<<<<] + >>>>>>[-<<<<<<+>>>>>>] + + # while cell 11 != 0 + << + [ + set cell 12 to 1 + >[-]+ + + set cell 11 to 0 + <[-] + + # end 11 + ] 11 + # add cell 12 to cell 7 + >[-<<<<<+>>>>>] + + # increment cell 6 + <<<<<<+ + < + end + ] 5 + + have now dealt with the non exit node + clear cell 9 + >>>> + [-] + end + ] 9 + + while cell 10 != 0 # at an exit + > + [ + copy cell 7 to cell 12 using cell 13 (highest) + <<<[->>>>>+>+<<<<<<] + >>>>>>[-<<<<<<+>>>>>>] + + while cell 12 != 0 (above ground level) + < + [ + copy cell 8 to cell 11 using cell 13 (highest) + <<<<[->>>+>>+<<<<<] + >>>>>[-<<<<<+>>>>>] + + cell 13 is zero + + ### subtract 11 from 12 ensuring 12 gte 0 + ### add 12 to 8 + + while cell 11 != 0 + << + [ + copy cell 12 to cell 14 using cell 15 + >[->>+>+<<<] + >>>[-<<<+>>>] + + while cell 14 != 0 + < + [ + set cell 13 to 1 + <[-]+ + decrement cell 14 + >- + end + ] 14 + while cell 13 != 0 + < + [ + decrement cell 12 + <- + decrement cell 13 + >- + end + ] 13 + + decrement cell 11 + <<- + end + ] 11 + + >[-<<<<+>>>>] + add cell 12 to cell 8 + ] 12 + << + clear 10 + [-] + ] 10 + + + + read character into cell 9 + <, +end +] 9 + +output cell 8 +<. + +""" + + +def execute(filename): + f = open(filename, "r") + evaluate(f.read()) + f.close() + + +def evaluate(code, inp=None, debug=False, execution_limit=0): + code = cleanup(list(code)) + bracemap = buildbracemap(code) + + cells, codeptr, cellptr = [0], 0, 0 + inputptr = 0 + execution_count = 0 + outputs = [] + + try: + while codeptr < len(code): + command = code[codeptr] + + if debug: + print(command, codeptr, cellptr, cells) + + if command == ">": + cellptr += 1 + if cellptr == len(cells): cells.append(0) + + if command == "<": + cellptr = 0 if cellptr <= 0 else cellptr - 1 + + if command == "+": + cells[cellptr] = cells[cellptr] + 1 if cells[cellptr] < 255 else 0 + + if command == "-": + cells[cellptr] = cells[cellptr] - 1 if cells[cellptr] > 0 else 255 + + if command == "[" and cells[cellptr] == 0: codeptr = bracemap[codeptr] + if command == "]" and cells[cellptr] != 0: codeptr = bracemap[codeptr] + if command == ".": + print(cells[cellptr]) # sys.stdout.write(chr(cells[cellptr])) + outputs += [cells[cellptr]] + if command == ",": + if inputptr >= len(inp): + # raise EOFError + cells[cellptr] = 0 + else: + cells[cellptr] = ord(inp[inputptr]) + inputptr += 1 + + codeptr += 1 + execution_count += 1 + if execution_limit != 0 and execution_count > execution_limit: + break + except EOFError: + pass + return cells, codeptr, cellptr, outputs + + +def cleanup(code): + return list(filter(lambda x: x in '.,[]<>+-', code)) + + +def buildbracemap(code): + temp_bracestack, bracemap = [], {} + + for position, command in enumerate(code): + if command == "[": temp_bracestack.append(position) + if command == "]": + start = temp_bracestack.pop() + bracemap[start] = position + bracemap[position] = start + return bracemap + +def main(): + + open('part2.bf', 'w').write(program + '\n') + inpt = '^=vvv=^^^=^=vv' + inpt = 'v^^^^^v=v=' + inpt = open('02-lifts.txt').read().strip() + # cells, codeptr, cellptr, outputs = evaluate(program, inp=inpt, execution_limit=200000, debug=True) + # cells, codeptr, cellptr, outputs = evaluate(program, inp=inpt, debug=True) + cells, codeptr, cellptr, outputs = evaluate(program, inp=inpt) + print(cells, codeptr, cellptr, outputs) + +if __name__ == "__main__": main() + \ No newline at end of file diff --git a/02-lifts/lifts-solution.ipynb b/02-lifts/lifts-solution.ipynb index bf60b78..723d33e 100644 --- a/02-lifts/lifts-solution.ipynb +++ b/02-lifts/lifts-solution.ipynb @@ -34,7 +34,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "metadata": { "collapsed": true }, @@ -51,7 +51,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 2, "metadata": { "collapsed": true }, @@ -66,7 +66,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -75,7 +75,7 @@ "209" ] }, - "execution_count": 4, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -89,7 +89,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 4, "metadata": { "collapsed": true }, @@ -106,7 +106,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -115,7 +115,7 @@ "(10002, 216, -6)" ] }, - "execution_count": 6, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -136,7 +136,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -145,7 +145,7 @@ "209" ] }, - "execution_count": 7, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -168,7 +168,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 7, "metadata": { "collapsed": true }, @@ -187,7 +187,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -196,7 +196,7 @@ "215" ] }, - "execution_count": 9, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -207,7 +207,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -216,7 +216,7 @@ "-5" ] }, - "execution_count": 10, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -227,7 +227,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -236,7 +236,7 @@ "209" ] }, - "execution_count": 11, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -247,7 +247,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -256,7 +256,7 @@ "-2" ] }, - "execution_count": 12, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -267,7 +267,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -276,7 +276,7 @@ "1259" ] }, - "execution_count": 13, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -287,7 +287,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 13, "metadata": {}, "outputs": [ { @@ -479,7 +479,7 @@ " 215: 2})" ] }, - "execution_count": 14, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -489,6 +489,26 @@ "collections.Counter(exits(instructions))" ] }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "-2" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "max(exits(instructions[:20]))" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/02-lifts/part1-brainfuck.ipynb b/02-lifts/part1-brainfuck.ipynb index 608180d..06487a8 100644 --- a/02-lifts/part1-brainfuck.ipynb +++ b/02-lifts/part1-brainfuck.ipynb @@ -2,8 +2,10 @@ "cells": [ { "cell_type": "code", - "execution_count": 121, - "metadata": {}, + "execution_count": 2, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "#!/usr/bin/python\n", @@ -27,6 +29,7 @@ "\n", " cells, codeptr, cellptr = [0], 0, 0\n", " inputptr = 0\n", + " output = []\n", "\n", " try:\n", " while codeptr < len(code):\n", @@ -50,20 +53,22 @@ "\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 == \".\": output += [cells[cellptr]] # 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", + " # raise EOFError\n", + " cells[cellptr] = 0\n", + " else:\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", + " return cells, codeptr, cellptr, output\n", "\n", "\n", "def cleanup(code):\n", @@ -91,7 +96,7 @@ }, { "cell_type": "code", - "execution_count": 128, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -100,7 +105,7 @@ "(118, 94, 61)" ] }, - "execution_count": 128, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -136,7 +141,7 @@ }, { "cell_type": "code", - "execution_count": 129, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -145,7 +150,7 @@ "24" ] }, - "execution_count": 129, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } @@ -156,7 +161,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 5, "metadata": { "collapsed": true }, @@ -167,23 +172,19 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 6, "metadata": {}, "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello World!\n" - ] - }, { "data": { "text/plain": [ - "([0, 0, 72, 100, 87, 33, 10], 106, 6)" + "([0, 0, 72, 100, 87, 33, 10],\n", + " 106,\n", + " 6,\n", + " [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33, 10])" ] }, - "execution_count": 20, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -194,35 +195,30 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 7, "metadata": {}, "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "hello" - ] - }, { "data": { "text/plain": [ - "([111], 3, 0)" + "([0], 5, 0, [104, 101, 108, 108, 111])" ] }, - "execution_count": 19, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "evaluate(',[.,]', input='hello')" + "evaluate(',[.,]', inp='hello')" ] }, { "cell_type": "code", - "execution_count": 196, - "metadata": {}, + "execution_count": 8, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "program = '>' + '+' * 94 + '>' + '+' * 24\n", @@ -292,16 +288,16 @@ }, { "cell_type": "code", - "execution_count": 200, + "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "([94, 94, 24, 0, 3, 0], 255, 5)" + "([94, 94, 24, 0, 3, 0], 259, 4, [3])" ] }, - "execution_count": 200, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -312,7 +308,7 @@ }, { "cell_type": "code", - "execution_count": 198, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -321,7 +317,7 @@ "'>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++<[-<+>>>+<<]>>[-<<+>>]>>,[<<<<<[->>>>>-<<<<<]>>>>>[<<<[->+<<<+>>]>[-<+>]<<<[->>>>>-<<<<<]>>>>>[<+>[-]]<-->]<+<<<[-<+>>>+<<]>>[-<<+>>]>>,]<.'" ] }, - "execution_count": 198, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -332,16 +328,47 @@ }, { "cell_type": "code", - "execution_count": 123, + "execution_count": 11, + "metadata": {}, + "outputs": [], + "source": [ + "with open('part1.clean.bf', 'w') as f:\n", + " for i, c in enumerate(''.join(cleanup(program))):\n", + " f.write('{:03} {}\\n'.format(i, c))" + ] + }, + { + "cell_type": "code", + "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "([60, 60, 0, 15, 0], 152, 4)" + "260" ] }, - "execution_count": 123, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "open('part1.clean.bf', 'w').write(''.join(cleanup(program))+'\\n')" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "([94, 94, 24, 0, 209, 0], 259, 4, [209])" + ] + }, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -353,7 +380,7 @@ }, { "cell_type": "code", - "execution_count": 124, + "execution_count": 13, "metadata": { "collapsed": true }, @@ -370,7 +397,7 @@ }, { "cell_type": "code", - "execution_count": 125, + "execution_count": 14, "metadata": { "collapsed": true }, @@ -385,7 +412,7 @@ }, { "cell_type": "code", - "execution_count": 126, + "execution_count": 15, "metadata": {}, "outputs": [ { @@ -394,7 +421,7 @@ "209" ] }, - "execution_count": 126, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -405,7 +432,7 @@ }, { "cell_type": "code", - "execution_count": 193, + "execution_count": 16, "metadata": { "scrolled": true }, @@ -414,56 +441,56 @@ "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" + "0 ([94, 94, 24, 0, 0, 0], 259, 4, [0]) \n", + "-1 ([94, 94, 24, 0, 255, 0], 259, 4, [255]) v\n", + "-2 ([94, 94, 24, 0, 254, 0], 259, 4, [254]) vv\n", + "-3 ([94, 94, 24, 0, 253, 0], 259, 4, [253]) vvv\n", + "-2 ([94, 94, 24, 0, 254, 0], 259, 4, [254]) vvv^\n", + "-1 ([94, 94, 24, 0, 255, 0], 259, 4, [255]) vvv^^\n", + "-2 ([94, 94, 24, 0, 254, 0], 259, 4, [254]) vvv^^v\n", + "-1 ([94, 94, 24, 0, 255, 0], 259, 4, [255]) vvv^^v^\n", + "-2 ([94, 94, 24, 0, 254, 0], 259, 4, [254]) vvv^^v^v\n", + "-2 ([94, 94, 24, 0, 254, 0], 259, 4, [254]) vvv^^v^v=\n", + "-3 ([94, 94, 24, 0, 253, 0], 259, 4, [253]) vvv^^v^v=v\n", + "-4 ([94, 94, 24, 0, 252, 0], 259, 4, [252]) vvv^^v^v=vv\n", + "-3 ([94, 94, 24, 0, 253, 0], 259, 4, [253]) vvv^^v^v=vv^\n", + "-4 ([94, 94, 24, 0, 252, 0], 259, 4, [252]) vvv^^v^v=vv^v\n", + "-3 ([94, 94, 24, 0, 253, 0], 259, 4, [253]) vvv^^v^v=vv^v^\n", + "-2 ([94, 94, 24, 0, 254, 0], 259, 4, [254]) vvv^^v^v=vv^v^^\n", + "-3 ([94, 94, 24, 0, 253, 0], 259, 4, [253]) vvv^^v^v=vv^v^^v\n", + "-4 ([94, 94, 24, 0, 252, 0], 259, 4, [252]) vvv^^v^v=vv^v^^vv\n", + "-5 ([94, 94, 24, 0, 251, 0], 259, 4, [251]) vvv^^v^v=vv^v^^vvv\n", + "-6 ([94, 94, 24, 0, 250, 0], 259, 4, [250]) vvv^^v^v=vv^v^^vvvv\n", + "-5 ([94, 94, 24, 0, 251, 0], 259, 4, [251]) vvv^^v^v=vv^v^^vvvv^\n", + "-4 ([94, 94, 24, 0, 252, 0], 259, 4, [252]) vvv^^v^v=vv^v^^vvvv^^\n", + "-5 ([94, 94, 24, 0, 251, 0], 259, 4, [251]) vvv^^v^v=vv^v^^vvvv^^v\n", + "-5 ([94, 94, 24, 0, 251, 0], 259, 4, [251]) vvv^^v^v=vv^v^^vvvv^^v=\n", + "-4 ([94, 94, 24, 0, 252, 0], 259, 4, [252]) vvv^^v^v=vv^v^^vvvv^^v=^\n", + "-4 ([94, 94, 24, 0, 252, 0], 259, 4, [252]) vvv^^v^v=vv^v^^vvvv^^v=^=\n", + "-3 ([94, 94, 24, 0, 253, 0], 259, 4, [253]) vvv^^v^v=vv^v^^vvvv^^v=^=^\n", + "-2 ([94, 94, 24, 0, 254, 0], 259, 4, [254]) vvv^^v^v=vv^v^^vvvv^^v=^=^^\n", + "-2 ([94, 94, 24, 0, 254, 0], 259, 4, [254]) vvv^^v^v=vv^v^^vvvv^^v=^=^^=\n", + "-1 ([94, 94, 24, 0, 255, 0], 259, 4, [255]) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^\n", + "0 ([94, 94, 24, 0, 0, 0], 259, 4, [0]) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^\n", + "1 ([94, 94, 24, 0, 1, 0], 259, 4, [1]) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^\n", + "1 ([94, 94, 24, 0, 1, 0], 259, 4, [1]) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=\n", + "2 ([94, 94, 24, 0, 2, 0], 259, 4, [2]) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^\n", + "3 ([94, 94, 24, 0, 3, 0], 259, 4, [3]) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^\n", + "4 ([94, 94, 24, 0, 4, 0], 259, 4, [4]) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^\n", + "3 ([94, 94, 24, 0, 3, 0], 259, 4, [3]) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v\n", + "3 ([94, 94, 24, 0, 3, 0], 259, 4, [3]) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=\n", + "4 ([94, 94, 24, 0, 4, 0], 259, 4, [4]) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^\n", + "5 ([94, 94, 24, 0, 5, 0], 259, 4, [5]) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^\n", + "6 ([94, 94, 24, 0, 6, 0], 259, 4, [6]) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^\n", + "6 ([94, 94, 24, 0, 6, 0], 259, 4, [6]) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^=\n", + "7 ([94, 94, 24, 0, 7, 0], 259, 4, [7]) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^=^\n", + "8 ([94, 94, 24, 0, 8, 0], 259, 4, [8]) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^=^^\n", + "7 ([94, 94, 24, 0, 7, 0], 259, 4, [7]) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^=^^v\n", + "8 ([94, 94, 24, 0, 8, 0], 259, 4, [8]) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^=^^v^\n", + "9 ([94, 94, 24, 0, 9, 0], 259, 4, [9]) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^=^^v^^\n", + "8 ([94, 94, 24, 0, 8, 0], 259, 4, [8]) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^=^^v^^v\n", + "9 ([94, 94, 24, 0, 9, 0], 259, 4, [9]) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^=^^v^^v^\n", + "8 ([94, 94, 24, 0, 8, 0], 259, 4, [8]) vvv^^v^v=vv^v^^vvvv^^v=^=^^=^^^=^^^v=^^^=^^v^^v^v\n" ] } ], @@ -474,7 +501,7 @@ }, { "cell_type": "code", - "execution_count": 194, + "execution_count": 17, "metadata": { "scrolled": true }, @@ -482,10 +509,10 @@ { "data": { "text/plain": [ - "(209, ([94, 94, 24, 0, 209, 0], 255, 5))" + "(209, ([94, 94, 24, 0, 209, 0], 259, 4, [209]))" ] }, - "execution_count": 194, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -496,13 +523,33 @@ }, { "cell_type": "code", - "execution_count": 199, + "execution_count": 21, "metadata": { "collapsed": true }, "outputs": [], "source": [ - "! bf -n part1.bf < 02-lifts.txt > part1.bf.out" + "! bf -n part1.clean.bf < 02-lifts.txt > part1.bf.out" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[209]" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "[int(b) for b in open('part1.bf.out', 'rb').read()]" ] }, { diff --git a/02-lifts/part1.clean.bf b/02-lifts/part1.clean.bf new file mode 100644 index 0000000..2199595 --- /dev/null +++ b/02-lifts/part1.clean.bf @@ -0,0 +1 @@ +>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++<[-<+>>>+<<]>>[-<<+>>]>>,[<<<<<[->>>>>-<<<<<]>>>>>[<<<[->+<<<+>>]>[-<+>]<<<[->>>>>-<<<<<]>>>>>[<+>[-]]<-->]<+<<<[-<+>>>+<<]>>[-<<+>>]>>,]<. diff --git a/02-lifts/part2-brainfuck.ipynb b/02-lifts/part2-brainfuck.ipynb index 0452e3b..af179f5 100644 --- a/02-lifts/part2-brainfuck.ipynb +++ b/02-lifts/part2-brainfuck.ipynb @@ -2,7 +2,18 @@ "cells": [ { "cell_type": "code", - "execution_count": 121, + "execution_count": 7, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "from IPython.utils import io" + ] + }, + { + "cell_type": "code", + "execution_count": 1, "metadata": { "collapsed": true }, @@ -29,6 +40,7 @@ "\n", " cells, codeptr, cellptr = [0], 0, 0\n", " inputptr = 0\n", + " outputs = []\n", "\n", " try:\n", " while codeptr < len(code):\n", @@ -52,20 +64,24 @@ "\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", + " outputs += [cells[cellptr]]\n", + " print(cells[cellptr]) # 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", + "# raise EOFError\n", + " cells[cellptr] = 0\n", + " else:\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", + " return cells, codeptr, cellptr, outputs\n", "\n", "\n", "def cleanup(code):\n", @@ -93,7 +109,7 @@ }, { "cell_type": "code", - "execution_count": 128, + "execution_count": 2, "metadata": {}, "outputs": [ { @@ -102,7 +118,7 @@ "(118, 94, 61)" ] }, - "execution_count": 128, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } @@ -135,7 +151,7 @@ " subtract cell 0 from cell 9\n", " if cell 9 == 0 we're at an exit\n", " if cell 7 != 0\n", - " if cell 6 is higher then cell 7\n", + " if cell 6 is higher than cell 7\n", " copy cell 6 into cell 7\n", " else\n", " subtract cell 2 from cell 9\n", @@ -148,59 +164,183 @@ " decrement cell 6\n", " \n", " copy cell 1 into cell 0 using cell 4\n", - " read character into cell 6\n", + " read character into cell 9\n", " \n", "output cell 7\n", + "```" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ "```\n", + "set cell 1 to 61 # exit\n", + "set cell 2 to 94-61=33 # up\n", + "set cell 3 to 118-94=24 # down\n", + "copy cell 1 into cell 0, using cell 4\n", + "\n", + "cell 5 for ???? currently at an exit: 1 if at an exit 0 otherwise\n", + "\n", + "set cell 6 to 0 (current level)\n", + "set cell 7 to for height above ground, min zero\n", + "set cell 8 to 0 (highest exit)\n", + "cell 9 for input\n", + "cell 10 for whether input has been dealt with: 0 for yes 1 for no\n", + "cell 11 for whether we've dealt with the height above zero cell\n", + "reserve cell 12 and higher for scratch\n", + "\n", + "\n", + "\n", "\n", - "```\n", "read character into cell 9\n", "set cell 10 to 1\n", - "while cell 9 != 0\n", - " subtract cell 0 from cell 9\n", - " while cell 9 == 0 we're not at an exit\n", - " subtract cell 1 from cell 9\n", + "while cell 9 != 0 # have an input\n", + " subtract cell 1 from cell 9\n", + " while cell 9 != 0 # we're not at an exit\n", " set cell 10 to 0\n", - " while cell 9 == 0 we're going up\n", - " increment cell 6\n", + " subtract cell 2 from cell 9\n", + " while cell 9 != 0 # we're going down\n", + " set cell 11 to 0\n", + " set cell 12 to 1\n", + " decrement cell 6\n", + " while cell 6 != 0 # haven't just descended to ground floor\n", + " while cell 7 != 0 # above ground\n", + " decrement cell 7\n", + " set cell 12 to 0 to finish loop\n", + " end\n", + " end\n", + " end\n", + " \n", + " while cell 11 != 0 # now deal with going up\n", + " set cell 12 to 1\n", + " while cell 6 != 0 # not on ground before going up\n", + " while cell 7 != 0 # above ground\n", + " increment cell 7\n", + " set cell 12 to 0 to finish the inner loop\n", + " end\n", + " set cell 12 to 0 to finish the loop\n", + " end\n", " increment cell 6\n", - " while cell 6 is zero\n", - " set cell 7 to zero \n", - " decrement cell 6\n", + " end\n", + " end\n", + " \n", " while cell 10 != 0 (at an exit)\n", " while cell 7 != 0 (above ground level)\n", " copy cell 8 to cell 11 using cell 13 (highest)\n", - " copy cell 6 to cell 12 using cell 13 (current)\n", + " copy cell 7 to cell 12 using cell 13 (current)\n", + " \n", " set cell 14 to 0\n", " while cell 11 != 0\n", - " increment cell 14\n", " while cell 12 != 0\n", " decrement cell 12\n", - " set cell 14 to 0, keep pointer at 14 (this exits the inner loop)\n", + " move pointer to 14 to terminate inner loop\n", + " end\n", " decrement cell 11\n", + " end\n", + " \n", " add cell 12 to cell 8\n", - " set cell 7 to 0\n", + " end\n", + " \n", + " copy cell 1 into cell 0 using cell 4\n", + " read character into cell 9\n", + " set cell 10 to 1\n", + "end \n", + "```\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "```\n", + "set cell 1 to 61 # exit\n", + "set cell 2 to 94-61=33 # up\n", + "set cell 3 to 118-94=24 # down\n", + "copy cell 1 into cell 0, using cell 4\n", + "\n", + "cell 5 for ???? currently at an exit: 1 if at an exit 0 otherwise\n", + "\n", + "set cell 6 to 0 (current level)\n", + "set cell 7 to for height above ground, min zero\n", + "set cell 8 to 0 (highest exit)\n", + "cell 9 for input\n", + "cell 10 for whether input has been dealt with: 0 for yes 1 for no\n", + "cell 11 for whether we've dealt with the height above zero cell\n", + "reserve cell 12 and higher for scratch\n", + "\n", + "\n", + "read character into cell 9\n", + "set cell 10 to 1\n", + "while cell 9 != 0 # have an input\n", + " subtract cell 1 from cell 9\n", + " while cell 9 != 0 # we're not at an exit\n", " set cell 10 to 0\n", - " \n", + " subtract cell 2 from cell 9\n", + " while cell 9 != 0 # we're going down\n", + " \n", + " while cell 6 != 0 # aren't descending from ground floor\n", + " copy cell 7 to cell 11 using cell 12\n", + " set cell 12 to 0\n", + " while cell 11 != 0 # above ground\n", + " set cell 12 to 1\n", + " decrement cell 11\n", + " end\n", + " while cell 12 != 0\n", + " decrement cell 7\n", + " decrement cell 12\n", + " end\n", + " end\n", + " decrement cell 6\n", + "\n", + " end\n", " \n", - " \n", - " \n", - " if cell 7 != 0\n", - " if cell 6 is higher then cell 7\n", - " copy cell 6 into cell 7\n", - " else\n", + " subtract cell 3 from cell 9\n", + " while cell 9 != 0 # we're going up\n", + " increment cell 6\n", + " while cell 6 != 0 # haven't just ascended to ground floor\n", + " copy cell 7 to cell 11 using cell 12\n", + " set cell 12 to 0\n", + " while cell 11 != 0\n", + " set cell 12 to 1\n", + " decrement cell 11\n", + " end\n", + " while cell 12 != 0\n", + " increment cell 7\n", + " decrement cell 12\n", + " end\n", + " end\n", + " end\n", + " \n", + " while cell 10 != 0 # at an exit\n", + " while cell 7 != 0 (above ground level)\n", + " copy cell 8 to cell 11 using cell 13 (highest)\n", + " copy cell 7 to cell 12 using cell 13 (current)\n", + " \n", + " # subtract 11 from 12, ensuring 12 >= 0\n", + " # add 12 to 8\n", " \n", + " while cell 11 != 0\n", + " set cell 13 to 0\n", + " copy cell 12 to cell 14 using cell 15\n", + " while cell 14 != 0\n", + " set cell 13 to 1\n", + " decrement cell 14\n", + " end\n", + " while cell 13 != 0\n", + " decrement cell 12\n", + " decrement cell 13\n", + " end\n", + " decrement cell 11\n", + " end\n", + " \n", + " add cell 12 to cell 8\n", + " \n", " copy cell 1 into cell 0 using cell 4\n", - " read character into cell 6\n", - "```\n", - "\n", - "```\n", - "Need a flag to say if below ground level, and only update the highest exit level if positive\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", + " read character into cell 9\n", + " set cell 10 to 1\n", + "end \n", + "output cell 8\n", "```\n" ] }, @@ -208,6 +348,242 @@ "cell_type": "code", "execution_count": 3, "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + ">+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>+++++++++++++++++++++++++++++++++>++++++++++++++++++++++++\n", + "\n", + "\n", + "read character into cell 9\n", + ">>>>>>,\n", + "\n", + "\n", + "\n", + "while cell 9 != 0 # have an input\n", + "[\n", + " set cell 10 to 1\n", + " >[-]+\n", + "\n", + " # clear cells 4 and 0\n", + " <<<<<<[-]<<<<[-]>\n", + " # copy cell 1 to cell 0 using cell 4\n", + " [-<+>>>>+<<<]\n", + " >>>[-<<<+>>>]\n", + " <<<<\n", + " \n", + " subtract cell 0 from cell 9 \n", + " [->>>>>>>>>-<<<<<<<<<]\n", + " >>>>>>>>>\n", + " \n", + " while cell 9 != 0 # we're not at an exit\n", + " [\n", + " set cell 10 to 0\n", + " >[-]\n", + " \n", + " copy cell 2 to cell 0 using cell 4\n", + " <<<<<<<<[-<<+>>>>+<<]\n", + " >>[-<<+>>]\n", + " <<<<\n", + " \n", + " subtract cell 0 from cell 9\n", + " [->>>>>>>>>-<<<<<<<<<]\n", + " >>>>>\n", + "\n", + " set cell 5 to 1\n", + " [-]+\n", + " >>>>\n", + "\n", + " \n", + " while cell 9 != 0 # we're going down\n", + " [\n", + " clear cell 5\n", + " <<<<[-]\n", + " copy cell 7 to cell 11 using cell 12\n", + " >>[->>>>+>+<<<<<]\n", + " >>>>>[-<<<<<+>>>>>]\n", + " \n", + " cell 12 is zero\n", + " \n", + " while cell 11 != 0 # above ground\n", + " <\n", + " [\n", + " set cell 12 to 1\n", + " >[-]+\n", + " \n", + " clear cell 11\n", + " <[-]\n", + " end\n", + " ] 11\n", + " \n", + " while cell 12 != 0\n", + " >\n", + " [\n", + " decrement cell 7\n", + " <<<<<-\n", + " \n", + " set cell 12 to zero\n", + " >>>>>[-]\n", + " end\n", + " ] 12\n", + " \n", + " <<<<<<\n", + " decrement cell 6\n", + " -\n", + " \n", + " have now dealt with the input so clear cell 9\n", + " >>>[-]\n", + " end\n", + " ] 9\n", + " \n", + " \n", + " while cell 5 != 0 # we're going up\n", + " <<<<\n", + " [\n", + " clear cell 5\n", + " [-]\n", + "\n", + "\n", + " # set cell 12 to 0\n", + " >>>>>>>[-]\n", + "\n", + " ### if 6 == 0 or 7 != 0\n", + " ### set cell 12 to 1\n", + "\n", + " # copy cell 6 to cell 11 using cell 12\n", + " <<<<<<[->>>>>+>+<<<<<<]\n", + " >>>>>>[-<<<<<<+>>>>>>]\n", + " \n", + " set cell 12 to 1\n", + " [-]+\n", + "\n", + " while cell 11 != 0\n", + " <\n", + " [\n", + " clear cell 12\n", + " >[-]\n", + "\n", + " set cell 11 to 0\n", + " <[-]\n", + " end 11\n", + " ] 11\n", + "\n", + "\n", + "\n", + " # copy cell 7 to cell 11 using cell 13\n", + " <<<<[->>>>+>>+<<<<<<]\n", + " >>>>>>[-<<<<<<+>>>>>>]\n", + "\n", + " # while cell 11 != 0\n", + " <<\n", + " [\n", + " set cell 12 to 1\n", + " >[-]+\n", + "\n", + " set cell 11 to 0\n", + " <[-]\n", + " \n", + " # end 11\n", + " ] 11\n", + " # add cell 12 to cell 7\n", + " >[-<<<<<+>>>>>]\n", + "\n", + " # increment cell 6\n", + " <<<<<<+\n", + " <\n", + " end\n", + " ] 5\n", + " \n", + " have now dealt with the non exit node\n", + " clear cell 9\n", + " >>>> \n", + " [-]\n", + " end\n", + " ] 9\n", + " \n", + " while cell 10 != 0 # at an exit\n", + " >\n", + " [\n", + " copy cell 7 to cell 12 using cell 13 (highest)\n", + " <<<[->>>>>+>+<<<<<<]\n", + " >>>>>>[-<<<<<<+>>>>>>]\n", + " \n", + " while cell 12 != 0 (above ground level)\n", + " <\n", + " [\n", + " copy cell 8 to cell 11 using cell 13 (highest)\n", + " <<<<[->>>+>>+<<<<<]\n", + " >>>>>[-<<<<<+>>>>>]\n", + " \n", + " cell 13 is zero\n", + " \n", + " ### subtract 11 from 12 ensuring 12 gte 0\n", + " ### add 12 to 8\n", + " \n", + " while cell 11 != 0\n", + " <<\n", + " [\n", + " copy cell 12 to cell 14 using cell 15\n", + " >[->>+>+<<<]\n", + " >>>[-<<<+>>>]\n", + " \n", + " while cell 14 != 0\n", + " <\n", + " [\n", + " set cell 13 to 1\n", + " <[-]+\n", + " decrement cell 14\n", + " >-\n", + " end\n", + " ] 14\n", + " while cell 13 != 0\n", + " <\n", + " [\n", + " decrement cell 12\n", + " <-\n", + " decrement cell 13\n", + " >-\n", + " end\n", + " ] 13\n", + " \n", + " decrement cell 11\n", + " <<-\n", + " end\n", + " ] 11\n", + " \n", + " >[-<<<<+>>>>]\n", + " add cell 12 to cell 8\n", + " ] 12\n", + " <<\n", + " clear 10\n", + " [-]\n", + " ] 10\n", + " \n", + " \n", + " \n", + " read character into cell 9\n", + " <,\n", + "end \n", + "] 9\n", + "\n", + "output cell 8\n", + "<.\n", + "\n", + "\n", + "\n" + ] + } + ], + "source": [ + "program = open('part2.bf').read()\n", + "print(program)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, "outputs": [ { "data": { @@ -215,7 +591,7 @@ "118" ] }, - "execution_count": 3, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } @@ -226,180 +602,132 @@ }, { "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "helloworld= '++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.'" - ] - }, - { - "cell_type": "code", - "execution_count": 20, + "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Hello World!\n" + "1\n" ] }, { "data": { "text/plain": [ - "([0, 0, 72, 100, 87, 33, 10], 106, 6)" + "([0, 61, 33, 24, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0], 698, 8, [1])" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "evaluate(program, inp='^=')" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "176223" ] }, - "execution_count": 20, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "evaluate(helloworld)" + "with io.capture_output() as captured:\n", + " evaluate(program, inp='^', debug=True)\n", + "\n", + "open('bf.log', 'w').write(captured.stdout)" ] }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "hello" + "1\n" ] }, { "data": { "text/plain": [ - "([111], 3, 0)" + "([0, 61, 33, 24, 0, 0, 3, 3, 1, 0, 0, 0, 0, 0], 698, 8, [1])" ] }, - "execution_count": 19, + "execution_count": 9, "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", - "\"\"\"" + "evaluate(program, inp='^^v=^^^v')" ] }, { "cell_type": "code", - "execution_count": 197, + "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "([94, 94, 24, 0, 3, 0], 255, 5)" + "'>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>+++++++++++++++++++++++++++++++++>++++++++++++++++++++++++>>>>>>,[>[-]+<<<<<<[-]<<<<[-]>[-<+>>>>+<<<]>>>[-<<<+>>>]<<<<[->>>>>>>>>-<<<<<<<<<]>>>>>>>>>[>[-]<<<<<<<<[-<<+>>>>+<<]>>[-<<+>>]<<<<[->>>>>>>>>-<<<<<<<<<]>>>>>[-]+>>>>[<<<<[-]>>[->>>>+>+<<<<<]>>>>>[-<<<<<+>>>>>]<[>[-]+<[-]]>[<<<<<->>>>>[-]]<<<<<<->>>[-]]<<<<[[-]>>>>>>>[-]<<<<<<[->>>>>+>+<<<<<<]>>>>>>[-<<<<<<+>>>>>>][-]+<[>[-]<[-]]<<<<[->>>>+>>+<<<<<<]>>>>>>[-<<<<<<+>>>>>>]<<[>[-]+<[-]]>[-<<<<<+>>>>>]<<<<<<+<]>>>>[-]]>[<<<[->>>>>+>+<<<<<<]>>>>>>[-<<<<<<+>>>>>>]<[<<<<[->>>+>>+<<<<<]>>>>>[-<<<<<+>>>>>]<<[>[->>+>+<<<]>>>[-<<<+>>>]<[<[-]+>-]<[<->-]<<-]>[-<<<<+>>>>]]<<[-]]<,]<.'" ] }, - "execution_count": 197, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "evaluate(program, inp='^^v=^^^v')" + "''.join(cleanup(program))" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "with open('part2.clean.bf', 'w') as f:\n", + " for i, c in enumerate(''.join(cleanup(program))):\n", + " f.write('{:03} {}\\n'.format(i, c))" ] }, { "cell_type": "code", - "execution_count": 198, + "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++<[-<+>>>+<<]>>[-<<+>>]>>,[<<<<<[->>>>>-<<<<<]>>>>>[<<<[->+<<<+>>]>[-<+>]<<<[->>>>>-<<<<<]>>>>>[<+>[-]]<-->]<+<<<[-<+>>>+<<]>>[-<<+>>]>>,]<.'" + "699" ] }, - "execution_count": 198, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "''.join(cleanup(program))" + "open('part2.clean.bf', 'w').write(''.join(cleanup(program))+'\\n')" ] }, { @@ -568,13 +896,33 @@ }, { "cell_type": "code", - "execution_count": 199, + "execution_count": 13, "metadata": { "collapsed": true }, "outputs": [], "source": [ - "! bf -n part1.bf < 02-lifts.txt > part1.bf.out" + "! bf -n part2.clean.bf < 02-lifts.txt > part2.bf.out" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[215]" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "[int(b) for b in open('part2.bf.out', 'rb').read()]" ] }, { diff --git a/02-lifts/part2.bf b/02-lifts/part2.bf new file mode 100644 index 0000000..0b430f4 --- /dev/null +++ b/02-lifts/part2.bf @@ -0,0 +1,218 @@ +>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>+++++++++++++++++++++++++++++++++>++++++++++++++++++++++++ + + +read character into cell 9 +>>>>>>, + + + +while cell 9 != 0 # have an input +[ + set cell 10 to 1 + >[-]+ + + # clear cells 4 and 0 + <<<<<<[-]<<<<[-]> + # copy cell 1 to cell 0 using cell 4 + [-<+>>>>+<<<] + >>>[-<<<+>>>] + <<<< + + subtract cell 0 from cell 9 + [->>>>>>>>>-<<<<<<<<<] + >>>>>>>>> + + while cell 9 != 0 # we're not at an exit + [ + set cell 10 to 0 + >[-] + + copy cell 2 to cell 0 using cell 4 + <<<<<<<<[-<<+>>>>+<<] + >>[-<<+>>] + <<<< + + subtract cell 0 from cell 9 + [->>>>>>>>>-<<<<<<<<<] + >>>>> + + set cell 5 to 1 + [-]+ + >>>> + + + while cell 9 != 0 # we're going down + [ + clear cell 5 + <<<<[-] + copy cell 7 to cell 11 using cell 12 + >>[->>>>+>+<<<<<] + >>>>>[-<<<<<+>>>>>] + + cell 12 is zero + + while cell 11 != 0 # above ground + < + [ + set cell 12 to 1 + >[-]+ + + clear cell 11 + <[-] + end + ] 11 + + while cell 12 != 0 + > + [ + decrement cell 7 + <<<<<- + + set cell 12 to zero + >>>>>[-] + end + ] 12 + + <<<<<< + decrement cell 6 + - + + have now dealt with the input so clear cell 9 + >>>[-] + end + ] 9 + + + while cell 5 != 0 # we're going up + <<<< + [ + clear cell 5 + [-] + + + # set cell 12 to 0 + >>>>>>>[-] + + ### if 6 == 0 or 7 != 0 + ### set cell 12 to 1 + + # copy cell 6 to cell 11 using cell 12 + <<<<<<[->>>>>+>+<<<<<<] + >>>>>>[-<<<<<<+>>>>>>] + + set cell 12 to 1 + [-]+ + + while cell 11 != 0 + < + [ + clear cell 12 + >[-] + + set cell 11 to 0 + <[-] + end 11 + ] 11 + + + + # copy cell 7 to cell 11 using cell 13 + <<<<[->>>>+>>+<<<<<<] + >>>>>>[-<<<<<<+>>>>>>] + + # while cell 11 != 0 + << + [ + set cell 12 to 1 + >[-]+ + + set cell 11 to 0 + <[-] + + # end 11 + ] 11 + # add cell 12 to cell 7 + >[-<<<<<+>>>>>] + + # increment cell 6 + <<<<<<+ + < + end + ] 5 + + have now dealt with the non exit node + clear cell 9 + >>>> + [-] + end + ] 9 + + while cell 10 != 0 # at an exit + > + [ + copy cell 7 to cell 12 using cell 13 (highest) + <<<[->>>>>+>+<<<<<<] + >>>>>>[-<<<<<<+>>>>>>] + + while cell 12 != 0 (above ground level) + < + [ + copy cell 8 to cell 11 using cell 13 (highest) + <<<<[->>>+>>+<<<<<] + >>>>>[-<<<<<+>>>>>] + + cell 13 is zero + + ### subtract 11 from 12 ensuring 12 gte 0 + ### add 12 to 8 + + while cell 11 != 0 + << + [ + copy cell 12 to cell 14 using cell 15 + >[->>+>+<<<] + >>>[-<<<+>>>] + + while cell 14 != 0 + < + [ + set cell 13 to 1 + <[-]+ + decrement cell 14 + >- + end + ] 14 + while cell 13 != 0 + < + [ + decrement cell 12 + <- + decrement cell 13 + >- + end + ] 13 + + decrement cell 11 + <<- + end + ] 11 + + >[-<<<<+>>>>] + add cell 12 to cell 8 + ] 12 + << + clear 10 + [-] + ] 10 + + + + read character into cell 9 + <, +end +] 9 + +output cell 8 +<. + + diff --git a/02-lifts/part2.bf.out b/02-lifts/part2.bf.out new file mode 100644 index 0000000..3416407 --- /dev/null +++ b/02-lifts/part2.bf.out @@ -0,0 +1 @@ +× \ No newline at end of file diff --git a/02-lifts/part2.clean.bf b/02-lifts/part2.clean.bf new file mode 100644 index 0000000..ad7e9af --- /dev/null +++ b/02-lifts/part2.clean.bf @@ -0,0 +1 @@ +>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>+++++++++++++++++++++++++++++++++>++++++++++++++++++++++++>>>>>>,[>[-]+<<<<<<[-]<<<<[-]>[-<+>>>>+<<<]>>>[-<<<+>>>]<<<<[->>>>>>>>>-<<<<<<<<<]>>>>>>>>>[>[-]<<<<<<<<[-<<+>>>>+<<]>>[-<<+>>]<<<<[->>>>>>>>>-<<<<<<<<<]>>>>>[-]+>>>>[<<<<[-]>>[->>>>+>+<<<<<]>>>>>[-<<<<<+>>>>>]<[>[-]+<[-]]>[<<<<<->>>>>[-]]<<<<<<->>>[-]]<<<<[[-]>>>>>>>[-]<<<<<<[->>>>>+>+<<<<<<]>>>>>>[-<<<<<<+>>>>>>][-]+<[>[-]<[-]]<<<<[->>>>+>>+<<<<<<]>>>>>>[-<<<<<<+>>>>>>]<<[>[-]+<[-]]>[-<<<<<+>>>>>]<<<<<<+<]>>>>[-]]>[<<<[->>>>>+>+<<<<<<]>>>>>>[-<<<<<<+>>>>>>]<[<<<<[->>>+>>+<<<<<]>>>>>[-<<<<<+>>>>>]<<[>[->>+>+<<<]>>>[-<<<+>>>]<[<[-]+>-]<[<->-]<<-]>[-<<<<+>>>>]]<<[-]]<,]<. -- 2.34.1