Find the hardest OEIS sequence to golf!

-5

Notice: This question originally had people write comments with a shorter program, rather than new answers. This has been changed so that people with shorter programs can get reputation too. Hopefully this doesn't become unmanageable...

There have been a couple of OEIS-related questions recently, so here's another:

Pick a sequence from the Online Encyclopedia of Integer Sequences, and write a full program or function which computes the sequence in one of the following ways:

  • It prints every term in the sequence in order
  • It takes an index in the sequence as input, and returns/outputs the term at that index.

You will be trying to pick the sequence with the longest possible shortest possible program/function to compute that sequence (see the example below if that's confusing). You must include which sequence you are using in your answer.

Try to make your program/function as short as possible. If anyone can find a shorter program which computes the same sequence, they should add a another answer with their shorter program. If you do find a shorter program than someone else, you should refer to their answer in yours. For all answers, a Try it Online link would be nice. If someone else has written a shorter program than yours, it would be nice if you put a link to it in your answer.

Of course, none of the programs should access the internet or the OEIS in any way, and they should all theoretically work on arbitrarily large inputs (you can ignore things like the maximum size of an integer type).

The sequence with the longest shortest program in bytes is the winner.

For example,

Let's say I pick the sequence A000027, the positive integers, and I submit this answer:

Python, 49 bytes, A000027

x = "o"
while True:
    print len(x)
    x += "o"

Obviously this is not a very short program for computing that sequence, so someone else (let's call them foo) might come along and add this answer:

Haskell, 2 bytes, A000027:

id

(id is the identity function, so it will just return whatever you pass into it, and because the nth positive integer is just n, it will compute that sequence).

Then, the person who posted the Python solution should edit their answer:

Python, 49 bytes, A000027

Superseded by foo's answer (link).

x = "o"
while True:
    print len(x)
    x += "o"

As long as no one else finds a shorter program, this sequence would get a score of 2 (because id is two bytes), and the sequence with the highest score wins.


Current best sequence: A014715, 252 bytes

Leo Tenenbaum

Posted 2019-07-11T11:56:29.197

Reputation: 2 655

Isn't this trivially just something like A060843?

– Expired Data – 2019-07-11T11:59:24.843

@ExpiredData A060483 would be impossible to submit as an answer, because you have to actually write a program to compute the sequence and include it in your answer. – Leo Tenenbaum – 2019-07-11T12:00:51.327

1The answer with the longest sequence is the winner. don't you mean that the answer with the longest answer in bytes is the winner? – Expired Data – 2019-07-11T12:04:25.303

@ExpiredData Oops, yes... – Leo Tenenbaum – 2019-07-11T12:05:24.387

1Should one update their answer with the current shortest program? – TFeld – 2019-07-11T12:50:47.963

@TFeld You can if you want, but you don't have to. – Leo Tenenbaum – 2019-07-11T12:53:17.857

5Honestly, the more I think about this question, the more it becomes obvious that the optimal strategy is finding challenges that are based on OEIS sequences and copying the shortest answer. – Stephen – 2019-07-11T12:54:39.133

@TFeld The answer/sequence is scored by the longest solution, including all comments. – Leo Tenenbaum – 2019-07-11T12:57:31.963

That's how I understood it as well, (which might encourage updating the answer), but it seems that others think that comments invalidate your answer. – TFeld – 2019-07-11T12:58:44.437

2This looks like a [tag:cops-and-robbers] done wrong because there's no incentive for the robbers. It might be worth taking it to the sandbox and enlisting mod help to lock it until it can be reworked. – Peter Taylor – 2019-07-11T21:31:03.577

@PeterTaylor I hadn't realized that comment upvotes don't give you reputation. I don't think that having the "robbers" post answers instead of comments would really work, because it would be hard to keep track of which person has the shortest solution for each question. Clearly this format is problematic, but I'm not sure if this question can be reworked. – Leo Tenenbaum – 2019-07-12T01:16:41.193

@Stephen Maybe, but so far that doesn't seem to be the case. – Leo Tenenbaum – 2019-07-12T01:17:04.020

Then again, maybe I'll just switch it to answers instead of comments. – Leo Tenenbaum – 2019-07-12T01:50:24.560

Answers

4

Wolfram Language (Mathematica), 270 252 bytes A014715

252 bytes, by Expired Data

RealDigits[NSolve[3x-6==Plus@@({6,-12,4,-7,7,-1,0,-5,2,4,12,-2,-7,-12,7,10,4,-3,-9,7,0,8,-14,3,-9,-2,3,10,2,6,-1,-10,3,-1,-7,7,-7,12,5,-8,-6,-10,8,8,7,3,-9,-1,-6,-6,2,3,10,2,-3,-5,-2,1,1,1,1,1,-1,-2,-2,1,2,1,0,-1}x^2~Range~71),x,#][[-1,-1,-1]]][[1,#]]&

Try it online!

I've never golfed in mathematica before, but the sequence seemed like an obvious contender. The code is more or less a copy of the example on the OEIS page.

The sequence is the decimal expansion of Conway's constant, which itself is the root of this polynomial:

\$x^{71}-x^{69}-2x^{68}-x^{67}+2x^{66}+2x^{65}+x^{64}-x^{63}-x^{62}-x^{61}-x^{60}-x^{59}+2x^{58}+5x^{57}+3x^{56}-2x^{55}-10x^{54}-3x^{53}-2x^{52}+6x^{51}+6x^{50}+x^{49}+9x^{48}-3x^{47}-7x^{46}-8x^{45}-8x^{44}+10x^{43}+6x^{42}+8x^{41}-5x^{40}-12x^{39}+7x^{38}-7x^{37}+7x^{36}+x^{35}-3x^{34}+10x^{33}+x^{32}-6x^{31}-2x^{30}-10x^{29}-3x^{28}+2x^{27}+9x^{26}-3x^{25}+14x^{24}-8x^{23}-7x^{21}+9x^{20}+3x^{19}-4x^{18}-10x^{17}-7x^{16}+12x^{15}+7x^{14}+2x^{13}-12x^{12}-4x^{11}-2x^{10}+5x^{9}+x^{7}-7x^{6}+7x^{5}-4x^{4}+12x^{3}-6x^{2}+3x-6\$

TFeld

Posted 2019-07-11T11:56:29.197

Reputation: 19 246

3Probably important to mention that the code is copied straight from the OEIS page for the sequence – Stephen – 2019-07-11T14:34:41.207

1261 bytes – Expired Data – 2019-07-11T15:37:48.167

And a few bytes more by jiggling the equation around – Expired Data – 2019-07-11T15:44:22.523

@Stephen Well, I did reverse the polynomial to save a few bytes :P – TFeld – 2019-07-11T16:03:50.323

@ExpiredData I've edited it into the answer. – TFeld – 2019-07-11T16:05:56.533

OEIS also lists a shorter solution in PARI/GP: P=Pol([1,0,-1,-2,-1,2,2,1,-1,-1,-1,-1,-1,2,5,3,-2,-10,-3,-2,6,6,1,9,-3,-7,-8,-8,10,6,8,-5,-12,7,-7,7,1,-3,10,1,-6,-2,-10,-3,2,9,-3,14,-8,0,-7,9,3,-4,-10,-7,12,7,2,-12,-4,-2,5,0,1,-7,7,-4,12,-6,3,-6]);polrootsreal(P)[3] – 219 bytes.

– Andriy Makukha – 2019-07-14T12:13:08.140

@AndriyMakukha I don't know any PARI, but feel free to turn that code into a function, and I'll edit the answer – TFeld – 2019-07-14T12:46:07.933

1

cQuents, 1 byte, A000027

$

Try it online!

Just to have a baseline answer in case every other answer is cracked.

Stephen

Posted 2019-07-11T11:56:29.197

Reputation: 12 293

6

Jelly, 0 bytes: Try it online! (sorry). Arguments are added to the stack in Jelly, and the top thing on the stack is printed when the program finishes, so the program takes an index as input, and outputs the corresponding term (which is just the same number).

– Leo Tenenbaum – 2019-07-11T12:32:55.587

@LeoTenenbaum ah, I remembered having the shortest answer to this and forgot that you had two different input styles

– Stephen – 2019-07-11T12:52:05.253

The 0 bytes version also works in GolfScript. Try it online!

– jimmy23013 – 2019-07-11T13:12:27.150

1

Python 3, 3 bytes, A055642

Finally, a ridiculously short answer that isn't just A000027 or some other stupidly simple sequence.

len

This is a function. Number should be inputted as a string of its digits. Undefined behavior for non-integers and other strings.

Cortex

Posted 2019-07-11T11:56:29.197

Reputation: 97