# OEIS的演变

56

1. 查找先前的答案，该答案可以在树的任何深度N处。
2. 确定该答案序列生成的前N个数字。
3. 在OEIS中找到一个序列，该序列以相同的数字开头并且之前从未使用过。
4. 编写一个程序以生成刚刚发现的这个新序列。
5. 将答案提交为深度N + 1

## 答案要求

`````` # [language], [number] bytes, depth [number], A[new sequence] from A[old sequence]
``````

``````# 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 ....
``````

## 链接要求

• 你不能束缚自己。
• 您不能将两个答案直接链接到同一祖先。
• 您不能做出多个“一级”答案。

## 计分

``````Answer Score = Sqrt(Depth) * 1024 / (Length + 256)
``````

``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&]*(?:&lt;(?:s&gt;[^&]*&lt;\/s&gt;|[^&]+&gt;)[^\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>``

5

Todd Lehman

3

2015年

2

Claudiu 2015年

1

Claudiu

1
SVG太窄了。
CalculatorFeline

21

# 括号，150字节，深度4，A000292从A000290

``````((()()())(()()()())((()())((()(()())))((()(())())((()()(()))(()(()()))((()(()))(()(()()))((())()))((()(()))(()(()()))((())()())))((())()()()()()()))))
``````

``````0, 1, 4, 10
``````

``````T(n) = n*(n+1)*(n+2)/6
``````

``````((()()()())((())()()()()()()()))
``````

## 带注释

``````(
define
(() ()())

f [][][]
(() ()()())

(
lambda
(() ())

(
n [[][]]
(() (()()))
)

(
div
(() (())())

(
*
(() ()(()))

n
(() (()()))

(
+
(() (()))

n
(() (()()))

1
((()) ())
)

(
+
(() (()))

n
(() (()()))

2
((()) ()())
)
)

6
((()) ()()()()()())
)
)
)

Test call:

(
f
(() ()()())

6
((()) ()()()()()())
)
``````

19

Alex A.

10
@AlexA。那不是Lisp！这是一种成熟的言语障碍！
CJ丹尼斯

18

# 煎饼堆，118字节，深度1，A000012

``````Put this kindercarnavalsoptochtvoorbereidingswerkzaamheden pancake on top!
Show me a pancake!
Eat all of the pancakes!
``````

``````1
``````

``````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 program
``````

## 上一个答案

``````Put 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
``````

17

# Python，31个字节，深度4，来自A000045的A010060

``lambda n:sum(map(ord,bin(n)))%2``

``````0, 1, 1, 0
``````

• `n`（在上面使用）的二进制扩展中的奇偶校验和
• 序列从0开始，然后重复添加到目前为止的序列的按位补码（即`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()
``````

15

# MarioLANG，265字节，深度3，来自A006370的A016957

``````                           <
=================="
(((+)< ))+(<
======" ===="
>-))+!  >-(!
"====#  "==#
>-(>[!))   >[!(  !
"====#=======#===#
;)++++++>[!))++++:
==========#=======
``````

``````4, 10, 16
``````

MarioLANG是一种深奥的编程语言，它基于Super Mario。以类似于Brainfuck的方式进行计算-有一条可以增加/减少的单元格。

``````+      Increment current memory cell
-      Decrement current memory cell
(      Move memory pointer left
)      Move memory pointer right
;      Numeric input
:      Numeric output
[      Skip next instruction is current cell is zero
``````

``````=      Ground for Mario to stand on
<      Make Mario move leftward
>      Make Mario move rightward
!      Make Mario stop moving
#      Elevator start
"      Elevator end
``````

``````Put input (n) in cell 0
Increment cell 1 to 6
While cell 1 is not zero...
Decrement cell 1
Move n from cell 0 to cells 2, 3
Move n from cell 2 to cell 0
Increment cell 3 by 4
Output as num
``````

12

# Brainfuck，2字节，深度2，来自A001477的A000030

``````,.
``````

A000030是非负整数的起始数字的序列，因此这仅读取了第一个数字字符并将其写回。下一个序列应以以下术语开头：

``````0, 1
``````

12

Alex A.

9

# Piet，16字节，深度3，从A000030开始的A000035

``````0, 1, 0
``````

9

# Marbelous，7个字节，深度3，来自A000027的A011760

``````}0
<D++
``````

``````1, 2, 3
``````

Marbelous是一种2D语言，其中数据以落在网格上的大理石（字节值）的形式流过代码。`}0`被第一个命令行参数替换。`<D`是一个开关，用作小于13的大理石（`D`位于底座36中）的空单元，因此输入1到12不会受到影响。如果大理石等于或大于13，则大理石向右偏斜并穿过，大理石将使`++`值增加1。在任何一种情况下，大理石都将从板上掉下来，并打印其值。

8

# 导轨，56字节，深度4，来自A002378的A033547

``````\$'main'
0/aima19-@
@------e<
/()(!!)-@
@-()m5a()m3do#
``````

``````0, 2, 6, 14
``````

Rail是一种2D语言，以火车轨道为主题。上面的代码使用`@`反射器打高尔夫球，该反射器使火车的方向反向，以减少换行符的数量。这里是无高尔夫球的：

``````\$ 'main'
\
0
\ /--aima19--\
|           |
\--e-------<
\
\-(!n!)-(n)-(n)-m-5-a-(n)-m-3-d-o-#
``````

``````0-9       Push 0-9 respectively
e         Push t (true) if EOF, else f (false)
i         Input char
o         Output
m         Multiply
(!n!)     Store top of stack as variable n
(n)       Push variable n to stack
#         Halt program
``````

8

# 星空，22字节，深度4，A008142起的A008619

``````      + + +*,  +   **.
``````

``````1, 1, 2, 2
``````

Starry是用Ruby实现的一种深奥语言，它是关于...用Ruby制作深奥语言的书的一部分。每条指令由之一前的空格数确定`+*.,`'`。所有其他字符都将被忽略，因此上述等效于

``````      +
+ +*,
+   *
*.
``````

``````Spaces     Final      Instruction
------     -----      -----------
n >= 5     +          Push n-5 to stack
1          +          Duplicate top of stack
0 mod 2    ,          Input num
2          +          Swap top 2
3 mod 5    *          Divide
0 mod 2    .          Output num
``````

## 上一个答案，53个字节

``````      +` +.               + + .  + +.  + .      +* +'
``````

``````Spaces     Final      Instruction
------     -----      -----------
1 mod 2    .          Output as ASCII char
n          `          Mark a label n
n          '          Pop and if nonzero, jump back to label n
``````

7

# Mathematica，20字节，深度6，来自A104631的A037965

``````Binomial[2#-2,#-1]#&
``````

``````0, 1, 4, 18, 80, 350
``````

CalculatorFeline

7

# CJam，34字节，深度14，来自A238263的A157271

``````qi_,_m*{~2@#3@#*}\$<::+1f&_:+\1-,e>
``````

``````1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7
``````

1

Claudiu 2015年

6

# Golfscript，3字节，深度3，从A000030开始的A000290

``````~2?
``````

``````0, 1, 4
``````

6

# 前奏，16字节，深度1，A000211

``````3(v!  v)
4 ^+2-^
``````

``````4
``````

6

# 剪辑，0字节，深度2，来自A000012的A000027

``````1, 2
``````

5

# J，4字节，深度4，来自A000290的A001563

``````(*!)
``````

``````0, 1, 4, 18
``````

ɐɔıʇǝɥʇuʎs

@ɐɔıʇǝɥʇuʎs我不会和任何说我不能在分数的〜1/128上把他们排除在外的人争论。:)
randomra 2015年

5

# Mathematica，48字节，深度5，来自A001563的A104631

``````SeriesCoefficient[((x^5-1)/(x-1))^#,{x,0,2#+1}]&
``````

``````0, 1, 4, 18, 80
``````

``````(1 + x + x^2 + x^3 + x^4)^n
``````

5

# 元素，13字节，深度3，A000030从A000030

``````1_'0[3:~2@+]`
``````

A000045代表斐波那契数。序列中的每一项都是前两项的总和。值得注意的是，连续项之间的比率接近黄金比率，也称为phi。有趣的是，OEIS条目以`0, 1`而不是common 开头`1, 1`。下一个答案应符合以下条件：

``````0, 1, 1
``````

5

# 序曲，1字节，深度2，A001477从A001477

``````!
``````

``````0, 0
``````

Prelude的优点在于，它在堆栈的底部具有无限的零供给，因此所需的只是一个输出命令。

4

# Perl，10个字节，深度为1，A001477

``````print\$_=<>
``````

``````0
``````

4

# GolfScript，9字节，深度4，来自A002275的A051682

``````~.9*7-*2/
``````

``````0, 1, 11, 30
``````

4

``````isdo
``````

``````0, 3
``````

4

# APL，13字节，深度4，来自A000142，A000108

``````{(⍵!2×⍵)÷⍵+1}
``````

``````1, 1, 2, 5
``````

4

# GolfScript，31字节，深度11，来自A242681的A029030

``````~][11.(2]{:C;{{.C-.)0>}do;}%}/,
``````

``````1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 7
``````

3
A258000：1、1、2、2、3、3、4、4、5、5、7、42-他们在codegolf.stackexchange.com上要求的一些奇怪的顺序

4

# 视网膜，1字节，深度3，来自A001333的A055642

``````.
``````

``````1, 1, 1
``````

3

# 剪辑，24字节，深度4，来自A002275的A049666

``````/F*5nx5[Fx?<x3O]+F(xF((x
``````

``````0, 1, 11, 122
``````

3

# 剪辑，37字节，深度5，来自A000292的A227327

``````[t/m++#t4*2#t3*8#t2?%t2+*2t9]*8t]48]n
``````

``````  X        X        X        .
X .      . .      . .      X X
. . .    X . .    . X .    . . .
``````

``````0, 1, 4, 10, 22
``````

3

# APL，24字节，深度6，来自A182712的A025581

``````{¯1-⍵-2!1+⌊.5+.5*⍨2×1+⍵}
``````

``````0, 1, 0, 2, 1, 0
``````

CalculatorFeline

3

# > <>，​​25字节，深度2，来自A002522的A001333

``````301-v >rn;
*2@:<r^!?:-1r+
``````

``````1, 1
``````

3

# J，44字节，深度10，来自A026233的A242681

``````f=.(,(<:*+)"0/~~.50,25,(,+:,3*])1+i.20)+/@:=]
``````

``````1, 1, 2, 2, 3, 3, 4, 4, 5, 5
``````

``````f 2 => 1
f 72 => 12
``````

3

# R，20字节，深度11，来自A242681的A194964

``````1+floor(scan()/5^.5)
``````

``````1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 5
``````