Skip to content

Instantly share code, notes, and snippets.

@dennissergeev
Last active September 24, 2017 08:43
Show Gist options
  • Save dennissergeev/7523872c5bf918506afa034869f69862 to your computer and use it in GitHub Desktop.
Save dennissergeev/7523872c5bf918506afa034869f69862 to your computer and use it in GitHub Desktop.
Tupper's self-referencing function
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "%matplotlib inline",
"execution_count": 1,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "import matplotlib.pyplot as plt",
"execution_count": 2,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "N = 4858450636189713423582095962494202044581400587983244549483093085061934704708809928450644769865524364849997247024915119110411605739177407856919754326571855442057210445735883681829823754139634338225199452191651284348332905131193199953502413758765239264874613394906870130562295813219481113685339535565290850023875092856892694555974281546386510730049106723058933586052544096664351265349363643957125565695936815184334857605266940161251266951421550539554519153785457525756590740540157929001765967965480064427829131488548259914721248506352686630476300\nH = 17\nW = 106",
"execution_count": 3,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "def tupper(x,y):\n return 0.5 < ((y//H) // (2**(H*x + y%H))) % 2",
"execution_count": 4,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "plt.rc('patch', antialiased=True)\nfor x in range(W):\n for yy in range(H):\n y = N + yy\n if tupper(x, y):\n plt.bar(left=x, bottom=yy, height=1, width=1, linewidth=0, color='black')\n\nplt.axis('scaled')\nbuf = 10\nplt.xlim((-buf,W+buf))\nplt.ylim((-buf,H+buf))\nplt.xticks(range(0, W, 100))\nplt.yticks([0, H], ['k', f'k + {H}']);",
"execution_count": 5,
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAACFCAYAAABBqm9MAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAB+5JREFUeJzt3U+IJPUZxv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NZT3wrIrbLZhp1QHTJ9l5EzPuuA8BwTW09wRATACBFQAAAUgREdWf7LgDA4E1q\nPcE2CABAih4EACBFQJSw/ZDt92xfsf103/UA6IftF2x/bPvSwrQ7bb9m+6/F3y8X0237uWK98bbt\n7/ZXeX0ExBK2b5f0G0k/knSvpMdt39tvVQB68ltJDx2a9rSkCxFxXNKF4rp0c51xvLjsSnq+oxpb\nRUAsd7+kKxHxfkTckPSKpJM91wSgBxHxuqR/H5p8UtKLxf8vSjq1MP13cdNfJH3J9te7qbQ9BMRy\nd0m6unB9v5gGAJL0tYj4uyQVf79aTJ/EuoOAWM7JNHb7AlBmEusOAmK5fUnfXLj+DUkf9VQLgOH5\nx8HQUfH342L6JNYdBMRyb0g6bvvbtu+Q9JikV3uuCcBwvCrpqeL/pySdW5j+s2Jvpu9LunYwFDUm\nx/ouYMgi4r+2fynpvKTbJb0QEZd7LgtAD2y/LOmHkrZs70v6taRnJf3B9i8k/U3S6WL2P0v6saQr\nkj6TdKbzglvAL6kBACmGmAAAKQICAJAiIAAAKQICAJAiIAAAKQICAJAiIAAAKQICAJD6H6+/ShMb\nlPNfAAAAAElFTkSuQmCC\n",
"text/plain": "<matplotlib.figure.Figure at 0x7fef6a578b70>"
},
"metadata": {},
"output_type": "display_data"
}
]
}
],
"metadata": {
"kernelspec": {
"name": "conda-env-phd-py",
"display_name": "Python [conda env:phd]",
"language": "python"
},
"language_info": {
"name": "python",
"version": "3.6.2",
"mimetype": "text/x-python",
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"pygments_lexer": "ipython3",
"nbconvert_exporter": "python",
"file_extension": ".py"
},
"gist": {
"id": "",
"data": {
"description": "Tupper's self-referencing function",
"public": true
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment