{ "cells": [ { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true, "toc": "true" }, "source": [ "# Table of Contents\n", "

1  Obfuscated code or piece of art?
1.1  Mandelbrot set
1.2  Penrose patterns
1.3  Bitcoin address & private key generator
" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "# Obfuscated code or piece of art?\n", "\n", "This short notebooks shows a few examples of Python code, designed to draw something, and shaped as what they will draw..." ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "## Mandelbrot set\n", "\n", "This nice little code will write a visualization of the [Mandelbrot set](https://en.wikipedia.org/wiki/Mandelbrot_set), on the domain $[-3, 3] \\times [-3i, 3i]$, for $1500 \\times 1500$ points, as a Bitmap (written manually in binary)." ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/usr/local/lib/python2.7/dist-packages/ipykernel/__main__.py:20: DeprecationWarning: integer argument expected, got float\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "CPU times: user 3min 43s, sys: 296 ms, total: 3min 44s\n", "Wall time: 3min 43s\n" ] } ], "source": [ "%%time\n", "b_ = (\n", " 255,\n", " lambda\n", " V ,B,c\n", " :c and Y(V*V+B,B, c\n", " -1)if(abs(V)<6)else\n", " ( 2+c-4*abs(V)**-0.4)/i\n", " ) ;v, x=1500,1000;C=range(v*x\n", " );import struct;P=struct.pack;M,\\\n", " j ='0@\"\"; U$:J(k.a2b_base\n", " 64(W));f=J(os.urando m(64)) %(H-U(\"AUVRIxl\n", "Qt1/EQC2hcy/JvsA=\"))+ 1;M$Q,R,G :((W*W-Q-G)%P,\n", "(W*(G+2*Q-W*W)-R)%P) ;P=H-2** 32-977;V$Q=P,L=\n", "1,O=0:V(Q%W,W,O-Q/W* L,L)if(W@O%P;S,\n", "T=A(f,U(\"eb5mfvncu6 xVoGKVzocLBwKb/Nst\n", "zijZWfKBWxb4F5g=\"), U(\"SDra dyajxGVdpPv8DhEI\n", "qP0XtEimhVQZnEfQj/ sQ1Lg=\"), 0,0);F$:\"1\"+F(W\n", " [1:])if(W[:1 ]==\"\\0\"@\"\" .join(map(B,C(\n", " J(W))));K$: F(W +Y(Y(W))[:4]);\n", " X.update(Y(\"\\4\"+ I(S)+I(T)));B$\n", " :re.sub(\"[0OIl _]| [^\\\\w]\",\"\",\"\".jo\n", " in(map(chr,ra nge (123))))[W];print\"Addre\n", " ss:\",K(\"\\0\"+X.dig est())+\"\\nPrivkey:\",K(\n", " \"\\x80\"+I(f))\"\"\";exec(reduce(lambda W,X:\n", " W.replace(*X),zip(\" \\n&$@\",[\"\",\"\",\n", " \" \",\"=lambda W,\",\")else \"])\n", " ,\"A$G,J,S,T:\"+_))" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "----\n", "\n", "Disclaimer: I am *not* the author of these small examples!\n", "\n", "> That's it for today!" ] } ], "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+" }, "toc": { "colors": { "hover_highlight": "#DAA520", "running_highlight": "#FF0000", "selected_highlight": "#FFD700" }, "moveMenuLeft": true, "nav_menu": { "height": "75px", "width": "252px" }, "navigate_menu": true, "number_sections": true, "sideBar": true, "threshold": 4, "toc_cell": true, "toc_section_display": "block", "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 2 }