28
4
This is a cops-and-robbers challenge. The robbers' thread is here.
An interesting question to think about is the following:
If I have a sequence of numbers how many of them do I have to provide before it is clear what sequence I am talking about?
For example if I want to talk about the positive integers in order starting from \$1\$, I could say \$1,2,3, \dots\$, but is that really enough?
I have one way of answering this question, and being a code-golfer it involves code-golf. You have provided enough terms of a sequence if the shortest code that produces those terms produces all the terms of the sequence. If we think about this in terms of code-golf, this would mean you have provided enough test cases such that the shortest code that passes the test-cases does the desired task.
Challenge
This challenge is a cops-and-robbers challenge. In which cops will be presenting test-cases and robbers will have to find a shorter way to spoof the test-cases other than the intended sequence. Cops will present the following things:
A piece of code that takes a non-negative integer as input and produces an integer as output. This code will define your sequence. Your code does not need to support 0 as an input, opting to instead take 1 as the smallest input. It should be clear if this is the case in your answer.
Any relevant platform or language requirements that might affect the output, for example the size of longint.
A number \$n\$, along with the first \$n\$ terms of the sequence as calculated by the code. These will act as "test-cases".
You are encouraged to explain what your sequence does and link OEIS if it exists, however it is your code that defines the sequence not the description.
Robbers will be finding a program in the same language that is shorter than the one presented and passes all the test cases (produces the same output for the first \$n\$ inputs as the cop's code). The robber's code must also differ in output from the cop's program for some number larger than \$n\$.
Cops must be able to crack their own answers before submitting them.
After one week a cop may reveal their crack and mark their answer as Safe. Answers marked as such can no longer be cracked.
Scoring
Cops answers will be scored by the number of bytes with fewer bytes being better. Cracked answers score an infinite score.
It's clear there are ways to un-mathematically crack a problem, like just printing all the test cases, but that issue is conditional on the cops' provided cases. Should there be a rule about that? Is there a restriction against computability of the sequences or anything from Ramsey Theory? (i.e. do you need to be able to crack on your machine?) – theREALyumdub – 2018-06-29T17:56:46.530
2@theReallyumdub the question stipulates you must be able to crack your own submission. – Post Rock Garf Hunter – 2018-06-29T18:02:36.053
@CatWizard Thanks, I went ahead and that's already on an obvious meta post, it impedes some of these guys apparently. So it isn't in the spirit of the tag to make a crack take over an hour to compute or something – theREALyumdub – 2018-06-29T18:12:45.707
4http://spikedmath.com/062.html – Giuseppe – 2018-06-29T20:35:49.800
Is there a "although theorically your solution must work for all numbers in practice it only need to work for ..." condition? – user202729 – 2018-06-30T01:54:09.127
@user202729 No there is not. You're sequence is defined simply by how your code works so if it diverges from whatever sequence you might intend to model because of the innacurracy of floating point numbers than that is that. The sequence is what your code outputs. – Post Rock Garf Hunter – 2018-06-30T02:55:45.450
Can the code use unary for I/O, or does it have to be decimal? – DLosc – 2018-06-30T05:16:08.083
@DLosc I'm just going to defer to the standard methods of IO. I believe that unary is allowed in some cases. – Post Rock Garf Hunter – 2018-06-30T14:46:30.767