用Tupper自我指涉公式造图
塔珀自指公式是杰夫·塔珀(Jeff Tupper)发现的自指公式:此公式的二维图像与公式本身外观一样。此公式在众多数学与计算机科学课程里被用作绘制公式图像的练习作业。
4858450636189713423582095962494202044581400587983244549483093085061934704708809928450644769865524364849997247024915119110411605739177407856919754326571855442057210445735883681829823754139634338225199452191651284348332905131193199953502413758765239264874613394906870130562295813219481113685339535565290850023875092856892694555974281546386510730049106723058933586052544096664351265349363643957125565695936815184334857605266940161251266951421550539554519153785457525756590740540157929001765967965480064427829131488548259914721248506352686630476300
@鄙视下维基百科给出的k是错的
时,然后将在和所示范围中符合以上不等式的点(x,y-k)绘制出来,结果会是这样:
函数的结果是函数本身图像,其实这个函数可以绘制任何图像,然后发给你心爱的人说,我发现个函数,k=多少多少时,会出现love you之类的,
我果然是理科生....=.=
过程是这样的,
- 我们绘制一个单色位图
- 然后我们将位图转换为2进制数值
- 逆向这个公式得到k
- =.= 检查图形美不美
1. 打开个文本
在107*17的范围内绘制图形如下,love YR ,哈哈YR是谁呢,注意长宽空格都算在内的
2.上代码,tupper.txt就是上面的文件
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import math def Base2_to_10(x):
ans = 0
i = 0
while x > 0:
if x%10 == 1: ans += 2**i
x /= 10
i += 1
return ans
def input():
bar = ""
for line in open('tupper.txt'):
for i in line[:-1]:
bar += i
code = ["" for i in xrange(17*107)]
for i in xrange(17*107-1):
#print i
x = i%107
y = 16- i/107
if bar[i] == "":
code[17*x+y] = ""
str = "".join(code)
return Base2_to_10(int(str[::-1]))*17
str = input()
print str
3 得到str
17395801135847186519514533766577166712920244599511619806806360198319443964624090437973069690063751432629635277541067512742591237154706476089604919941282726117482657226986792284460049763364287128660374652834353819138510460422151182573412890443751441495242184763277437223648251193921175808287491778837040326348124920816742193510432149378864985078857052059037920621670314430604882179347284818468370754314529752114472995398250019563369691397252465478396117000433401686853725151310746693542808908025107928533841248521147887035746484088
4.用官方的代码跑一下效果
"""
Copyright (c) 2012, 2013 The PyPedia Project, http://www.pypedia.com
<br>All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: # Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
# Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. http://www.opensource.org/licenses/BSD-2-Clause
""" __pypdoc__ = """
Method: Tupper_self_referential_formula
Link: http://www.pypedia.com/index.php/Tupper_self_referential_formula
Retrieve date: Tue, 11 Mar 2014 03:15:49 +0200 Plots the [http://en.wikipedia.org/wiki/Tupper's_self-referential_formula Tupper's_self-referential_formula]:
: <math>{1\over 2} < \left\lfloor \mathrm{mod}\left(\left\lfloor {y \over 17} \right\rfloor 2^{-17 \lfloor x \rfloor - \mathrm{mod}(\lfloor y\rfloor, 17)},2\right)\right\rfloor</math> The plot is the very same formula that generates the plot. [[Category:Validated]]
[[Category:Algorithms]]
[[Category:Math]]
[[Category:Inequalities]] """ def Tupper_self_referential_formula():
k = 17395801135847186519514533766577166712920244599511619806806360198319443964624090437973069690063751432629635277541067512742591237154706476089604919941282726117482657226986792284460049763364287128660374652834353819138510460422151182573412890443751441495242184763277437223648251193921175808287491778837040326348124920816742193510432149378864985078857052059037920621670314430604882179347284818468370754314529752114472995398250019563369691397252465478396117000433401686853725151310746693542808908025107928533841248521147887035746484088
#love yiran def f(x,y):
d = ((-17 * x) - (y % 17))
e = reduce(lambda x,y: x*y, [2 for x in range(-d)]) if d else 1
f = ((y / 17) / e)
g = f % 2
return 0.5 < g for y in range(k+16, k-1, -1):
line = ""
for x in range(0, 107):
if f(x,y):
line += "@"
else:
line += " "
print line #Method name =Tupper_self_referential_formula()
if __name__ == '__main__':
# print __pypdoc__ returned = Tupper_self_referential_formula()
if returned:
print str(returned)
Tupper_self_referential_formula.py
5.得到效果
love 依然~~
参考:
http://www.matrix67.com/blog/archives/301
http://www.zhihu.com/question/22506052/answer/21583549
http://zh.wikipedia.org/wiki/%E5%A1%94%E7%8F%80%E8%87%AA%E6%8C%87%E5%85%AC%E5%BC%8F
用Tupper自我指涉公式造图的更多相关文章
- Tupper自我指涉公式生成器
- 志愿者招募 HYSBZ - 1061(公式建图费用流)
转自神犇:https://www.cnblogs.com/jianglangcaijin/p/3799759.html 题意:申奥成功后,布布经过不懈努力,终于 成为奥组委下属公司人力资源部门的主管. ...
- unctf2020 部分简单题题解
unctf2020 水一波简单题..菜狗前来报道..大佬轻喷..如果有时间做题就好了呜呜呜 misc 1.baba_is_you 题目告诉我们,了解png文件格式. 下载得到一张png格式的图片. 用 ...
- 【seo】title / robots / description / canonical
1.title title,就是浏览器上显示的那些内容,不仅用户能看到,也能被搜索引擎检索到(搜索引擎在抓取网页时,最先读取的就是网页标题,所以title是否正确设置极其重要. 1)title一般不超 ...
- 机器学习&数据挖掘笔记_20(PGM练习四:图模型的精确推理)
前言: 这次实验完成的是图模型的精确推理.exact inference分为2种,求边缘概率和求MAP,分别对应sum-product和max-sum算法.这次实验涉及到的知识点很多,不仅需要熟悉图模 ...
- Effective C++_笔记_条款11_在operator=中处理“自我赋值”
(整理自Effctive C++,转载请注明.整理者:华科小涛@http://www.cnblogs.com/hust-ghtao/) 为什么会出现自我赋值呢?不明显的自我赋值,是“别名”带来的结果: ...
- SVG的动态之美-搜狗地铁图重构散记
搜狗地图发布了新版的移动端地铁图,改版初衷是为了用户交互体验的提升以及性能的改善.原版地铁图被用户吐槽最多的是pinch缩放不流畅.无过渡动画.拖拽边界不合理等等,大体上都是交互体验上的问题.实际上原 ...
- 定义工作,解读自我——IT帮2019年2月线下活动回顾
本次活动是在北京和深圳两个分站同步进行的,IT团建委员会负责策划和组织,北京站由帮主周老师.王兵老师主导,深圳站由副帮主兼深圳站长陈焕老师主导. 几位老师都是有着丰富的工作经历和人生体验的导师,他们不 ...
- Spark学习之路 (二十七)图简介
一.图 1.1 基本概念 图是由顶点集合(vertex)及顶点间的关系集合(边edge)组成的一种数据结构. 这里的图并非指代数中的图.图可以对事物以及事物之间的关系建模,图可以用来表示自然发生的连接 ...
随机推荐
- http://www.cnblogs.com/
<?php $filename = $_GET['filename']; header("Content-type: application/octet-stream"); ...
- Gvim 在进行文件对比时报cannot read or write temp files
本机环境为win7 64位旗舰版,gvim安装的是GVim7.4.解决办法如下: 在安装目录下有个"_vimrc"文件.修改19行.将 if &sh =~ '\<cm ...
- 双系统Linux(ubuntu)进入windows的NTFS分区之挂载错误
自从装了双系统(ubuntu&win10)后,发现有时在ubuntu下无法进行win磁盘,于是在网上搜了点资料得以解决,并在此记录一下: 问题如下: 解决步骤: 1.ctrl+alt+t打开终 ...
- JavaScript对Json的增删改属性
<script type="text/javascript"> var json = { "age":24, "name":&q ...
- Picker组件封装
在开发APP的过程中,我们可能会遇上软件中需要有很多下拉选择样式,就像之前我做的那个<房贷计算器>一样,有很多下拉选择,如果没有将Picker封装起来共用是很麻烦的. 安装插件 在Reac ...
- DWZ按钮居中显示
- UISearchDisplayController隐藏navigationBar需注意
不能调用self.navigationController.navigationBar.hidden = YES: 调用此代码的话,你隐藏了navigationBar搜索展示控制器就拿不到导航条:就会 ...
- ORA-01502错误成因和解决方法
这个错误是由于索引失效造成的,重建索引后,问题就解决了. 我们看到,当使用类似 alter table xxxxxx move tablespace xxxxxxx 命令后,索引就会失效. 当然,作为 ...
- 前端工作流程自动化——Grunt/Gulp 自动化
什么是自动化 先来说说为什么要自动化.凡是要考虑到自动化时,你所做的工作必然是存在很多重复乏味的劳作,很有必要通过程序来完成这些任务.这样一来就可以解放生产力,将更多的精力和时间投入到更多有意义的事情 ...
- GridViewWIthSubActivityDemo
GridViewWIthSubActivityDemo 拥有一个sub-activity的GridView示例: 显示一系列图片,点击其中之一的话,在新的sub-activity中放大显示. Imag ...