在这个挑战中,我们的目标是每次重新创建一个整数序列在线百科全书序列。与哈罗世界的演变类似,每个答案都取决于先前的答案。
随着时间的推移,这一挑战将创造一个“家族树”的OEIS序列。添加到这棵树上很简单。
因为你的答案影响评分,所以你应该尽可能地把你的答案加到树上。如果你不能在树上的任何地方匹配你的答案,你可以开始树的一个新的分支,并把你的答案作为深度1。
有几种方法可以输出序列。
第一个选项是编写一个程序或函数,输入一个数字(来自STDIN或作为参数),并以所选的顺序返回N个数字。您可以假设序列是为N定义的,并且N和S_N是“合理大小的”(因此不会导致溢出)。您也可以使用任何合理的索引,如0索引,1索引,或索引列在序列的OEIS页面上的“偏移”下,这并不重要。第一个索引产生的术语必须与OEIS条目的第一个项相匹配。
第二个选项是编写一个程序或函数,输入一个数字并返回序列的第一个N项。输出的第一个项必须是OEIS条目的第一个项(不能忽略前几个项)。连续的术语必须由非数字字符的任意字符串分隔,因此0,1 1.2/3,5;8,11工作,但011235811不计算。
第三种选择是创建一个输出连续数字流的程序。与第二个选项类似,在连续的术语之间必须有分隔符。
您的答案应该包含这样的标题,以帮助Stack代码段解析:
# [language], [number] bytes, depth [number], A[new sequence] from A[old sequence] 您的答案应该包含生成序列的代码,以及任何后代都需要包含的前几个术语。这几个术语之前应该有确切的单词terms:,以便控制器可以将它们作为树形图的一部分使用。还建议编写对所选序列的描述。
如果您的帖子是深度1答案,因此没有祖先,那么您应该简单地省略标题中的from A[number]。
下面是一个例子:
# Perl, 26 bytes, depth 3, A026305 from A084912
various code here
and here
The next answer should match the following terms:
1, 4, 20
This sequence is .... and does ....为了使这一挑战更加公平,有一些限制,你可以把你的答案锁在上面。这些规则主要是为了防止单个人自己创建整个树分支,或者拥有许多“根”节点。
此外,如果祖先的深度为N,则您的帖子必须具有深度N+1,即使超过所需的术语数量也是如此。
你作为一个用户的分数是你所有答案的分数之和。单一答案的得分由以下公式决定:
Answer Score = Sqrt(Depth) * 1024 / (Length + 256)这个评分系统应该鼓励用户提交大量更深层次的答案。较短的答案比较长的答案更可取,但深度的影响要大得多。
下面是一个堆栈片段,它生成一个领导板以及所有答案的树状图。我想感谢马丁·布特纳和d3noob作为大量代码的来源。您应该点击“全屏”来查看完整的结果。
function answersUrl(t){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+t+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(t){answers.push.apply(answers,t.items),t.has_more?getAnswers():process()}})}function shouldHaveHeading(t){var e=!1,r=t.body_markdown.split("\n");try{e|=/^#/.test(t.body_markdown),e|=["-","="].indexOf(r[1][0])>-1,e&=LANGUAGE_REG.test(t.body_markdown)}catch(a){}return e}function shouldHaveScore(t){var e=!1;try{e|=SIZE_REG.test(t.body_markdown.split("\n")[0])}catch(r){}return e}function getAuthorName(t){return t.owner.display_name}function decodeEntities(t){return $("<textarea>").html(t).text()}function process(){answers=answers.filter(shouldHaveScore).filter(shouldHaveHeading),answers.reverse();var t={},e=[],r=1,a=null,n=1,s=[];answers.forEach(function(t){var r=t.body_markdown.split("\n")[0],a=getAuthorName(t),n=r.match(SEQUENCE_REG)[0];n=n.trim();var o="from A000000";PARENT_REG.test(r)&&(o=r.match(PARENT_REG)[0]),o=o.substring(5).trim(),"A000000"==o&&(o="OEIS");var i="";SEQDATA_REG.test(t.body_markdown)&&(i=t.body_markdown.match(SEQDATA_REG)[1]);for(var u=!0,c=0;c<e.length;++c)u=u&&!(e[c]===n);for(var l=!0,c=0;c<e.length;++c)l=!(!l||e[c]===n||e[c]===n+a||e[c]===o+a);e.push(n),e.push(n+a),e.push(o+a),u&&data.push({name:n,parent:o,term:i+" : ",author:decodeEntities(a),URL:t.share_link}),l&&s.push(t)}),answers.sort(function(t,e){var r=t.body_markdown.split("\n")[0].match(SEQUENCE_REG),a=e.body_markdown.split("\n")[0].match(SEQUENCE_REG);return a>r?-1:r>a?1:void 0}),answers.forEach(function(e){var o=e.body_markdown.split("\n")[0],i=(o.match(NUMBER_REG)[0],(o.match(SIZE_REG)||[0])[0]),u=parseInt((o.match(DEPTH_REG)||[0])[0]).toString(),c=o.match(SEQUENCE_REG)[0],l="from A000000";PARENT_REG.test(o)&&(l=o.match(PARENT_REG)[0]),l=l.substring(5);var d=o.match(LANGUAGE_REG)[1];d.indexOf("]")>0&&(d=d.substring(1,d.indexOf("]")));for(var p=getAuthorName(e),E=!1,h=0;h<s.length;++h)E=E||s[h]===e;if(E){var f=jQuery("#answer-template").html();i!=a&&(n=r),a=i,++r;var m=1024*Math.pow(parseInt(u),.5)/(parseInt(i)+256);f=f.replace("{{SEQUENCE}}",c).replace("{{SEQUENCE}}",c).replace("{{NAME}}",p).replace("{{LANGUAGE}}",d).replace("{{SIZE}}",i).replace("{{DEPTH}}",u).replace("{{LINK}}",e.share_link),f=jQuery(f),jQuery("#answers").append(f),t[p]=t[p]||{lang:d,user:p,size:"0",numanswers:"0",link:e.share_link},t[p].size=(parseFloat(t[p].size)+m).toString(),t[p].numanswers=(parseInt(t[p].numanswers)+1).toString()}});var o=[];for(var i in t)t.hasOwnProperty(i)&&o.push(t[i]);o.sort(function(t,e){return parseFloat(t.size)>parseFloat(e.size)?-1:parseFloat(t.size)<parseFloat(e.size)?1:0});for(var u=0;u<o.length;++u){var c=jQuery("#language-template").html(),i=o[u];c=c.replace("{{RANK}}",u+1+".").replace("{{NAME}}",i.user).replace("{{NUMANSWERS}}",i.numanswers).replace("{{SIZE}}",i.size),c=jQuery(c),jQuery("#languages").append(c)}createTree()}function createTree(){function t(){var t=i.nodes(root).reverse(),e=i.links(t);t.forEach(function(t){t.y=180*t.depth});var r=c.selectAll("g.node").data(t,function(t){return t.id||(t.id=++o)}),a=r.enter().append("g").attr("class","node").attr("transform",function(t){return"translate("+t.y+","+t.x+")"});a.append("a").attr("xlink:href",function(t){return t.URL}).append("circle").attr("r",10).style("fill","#fff"),a.append("text").attr("x",function(){return 0}).attr("y",function(){return 20}).attr("dy",".35em").attr("text-anchor",function(){return"middle"}).text(function(t){return t.term+t.name}).style("fill-opacity",1),a.append("text").attr("x",function(){return 0}).attr("y",function(){return 35}).attr("dy",".35em").attr("text-anchor",function(){return"middle"}).text(function(t){return t.author}).style("fill-opacity",1);var n=c.selectAll("path.link").data(e,function(t){return t.target.id});n.enter().insert("path","g").attr("class","link").attr("d",u)}var e=data.reduce(function(t,e){return t[e.name]=e,t},{}),r=[];data.forEach(function(t){var a=e[t.parent];a?(a.children||(a.children=[])).push(t):r.push(t)});var a={top:20,right:120,bottom:20,left:120},n=3203-a.right-a.left,s=4003-a.top-a.bottom,o=0,i=d3.layout.tree().size([s,n]),u=d3.svg.diagonal().projection(function(t){return[t.y,t.x]}),c=d3.select("body").append("svg").attr("width",n+a.right+a.left).attr("height",s+a.top+a.bottom).append("g").attr("transform","translate("+a.left+","+a.top+")");root=r[0],t(root)}var QUESTION_ID=49223,ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",data=[{name:"OEIS",parent:"null",term:"",author:"",URL:"https://oeis.org/"}],answers=[],page=1;getAnswers();var SIZE_REG=/\d+(?=[^\d&]*(?:<(?:s>[^&]*<\/s>|[^&]+>)[^\d&]*)*,)/,DEPTH_REG=/\d+, A/,NUMBER_REG=/\d+/,LANGUAGE_REG=/^#*\s*([^,]+)/,SEQUENCE_REG=/A\d+/,PARENT_REG=/from\s*A\d+/,SEQDATA_REG=/terms:\s*(?:(?:-)?\d+,\s*)*((?:-)?\d+)/;body{text-align: left !important}#answer-list{padding: 10px; width: 550px; float: left;}#language-list{padding: 10px; width: 290px; float: left;}table thead{font-weight: bold;}table td{padding: 5px;}.node circle{fill: #fff; stroke: steelblue; stroke-width: 3px;}.node text{font: 12px sans-serif;}.link{fill: none; stroke: #ccc; stroke-width: 2px;}<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><script src="http://d3js.org/d3.v3.min.js"></script><link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"><div id="answer-list"> <h2>Sequence List</h2> <table class="answer-list"> <thead> <tr> <td>Sequence</td><td>Author</td><td>Language</td><td>Size</td><td>Depth</td></tr></thead> <tbody id="answers"></tbody> </table></div><div id="language-list"> <h2>Leaderboard</h2> <table class="language-list"> <thead> <tr> <td>Rank</td><td>User</td><td>Answers</td><td>Score</td></tr></thead> <tbody id="languages"></tbody> </table></div><table style="display: none"> <tbody id="answer-template"> <tr> <td><a href="https://oeis.org/{{SEQUENCE}}">{{SEQUENCE}}</a></td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td>{{DEPTH}}</td><td><a href="{{LINK}}">Link</a> </td></tr></tbody></table><table style="display: none"> <tbody id="language-template"> <tr> <td>{{RANK}}</td><td>{{NAME}}</td><td>{{NUMANSWERS}}</td><td>{{SIZE}}</td></tr></tbody></table>发布于 2015-04-26 16:40:58
的A000292
((()()())(()()()())((()())((()(()())))((()(())())((()()(()))(()(()()))((()(()))(()(()()))((())()))((()(()))(()(()()))((())()())))((())()()()()()()))))下一个答案应与以下术语相匹配:
0, 1, 4, 10这是四面体数的序列,三角形数的三维推广。这个公式是
T(n) = n*(n+1)*(n+2)/6圆括号是一种类似Lisp的语言,它使用括号来定义一切。上面是一个函数()()(),它接受n并输出T(n)。打电话给:
((()()()())((())()()()()()()()))(
define
(() ()())
f [][][]
(() ()()())
(
lambda
(() ())
(
n [[][]]
(() (()()))
)
(
div
(() (())())
(
*
(() ()(()))
n
(() (()()))
(
+
(() (()))
n
(() (()()))
1
((()) ())
)
(
+
(() (()))
n
(() (()()))
2
((()) ()())
)
)
6
((()) ()()()()()())
)
)
)
Test call:
(
f
(() ()()())
6
((()) ()()()()()())
)发布于 2015-04-26 18:53:48
Put this kindercarnavalsoptochtvoorbereidingswerkzaamheden pancake on top!
Show me a pancake!
Eat all of the pancakes!下一个答案应与以下术语相匹配:
1这将打印n的最小除数。在esolang wiki页面上使用Python解释器进行测试。解释器期望行后的~表示程序的结束,然后是STDIN输入(无论如何都会被忽略)。
有关指示:
Put this <blah> pancake on top! # Push length of <blah>
Show me a pancake! # Output top of stack as char
Eat all of the pancakes! # Terminate the programPut this pancake on top!
[]
Put this kindercarnavalsoptochtvoorbereidingswerkzaamheden pancake on top!
Show me a pancake!
Put this delectable pancake on top!
Show me a pancake!
If the pancake is tasty, go over to "".这个在无限循环中打印。附加指示:
[<blah>] # Define the label <blah>
If the pancake is tasty, go over to "<blah>". # If top of stack nonzero, go to label还有其他的说明,但是即使这样,Pancake的使用仍然非常麻烦,这要归功于缺少数字输出和对堆栈前两个元素的访问。
不幸的是,这个程序的第一行似乎是必要的,以防止与Python解释器中的标签有关的错误。
发布于 2015-04-27 17:32:23
的A010060
lambda n:sum(map(ord,bin(n)))%2下一个答案应与以下术语相匹配:
0, 1, 1, 0这个是我最喜欢的,也是Thue-Morse序列。它至少有两个定义:
n二进制展开中的奇偶性(上面使用),以及0 -> 01 -> 0110 -> 01101001 -> ...)这个序列中有一件很酷的事情是,如果我们抓起一只乌龟然后做:
import turtle
turtle.speed(0)
n = 12
# Calculate first 2^n of Thue-Morse
tm = map(lambda n:sum(map(ord,bin(n)))%2, range(2**n))
# Move to top left
turtle.penup()
turtle.setx(-300)
turtle.sety(300)
turtle.pendown()
# For each num, go forward a unit if 0, or turn left 120 degrees if 1
for m in tm:
if m == 0:
turtle.forward(1)
elif m == 1:
turtle.left(120)
turtle.hideturtle()
turtle.mainloop()我们得到了这个:

看起来很眼熟?
https://codegolf.stackexchange.com/questions/49223
复制相似问题