-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 n
th 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
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