84
13
Cops section
The robbers section can be found here.
Thanks to FryAmTheEggman, Peter Taylor, Nathan Merrill, xnor, Dennis, Laikoni and Mego for their contributions.
Challenge
Your task is to write 2 different programs (full programs/functions/etc.) in the same language and the same version (e.g. Python 3.5 ≠ Python 3.4, so that is not allowed), and when given n (using STDIN/function arguments/etc.), compute a(n) where a is an OEIS sequence of your choice. One of those programs is shorter than the other. You only need to submit the longer program of the two. The other one needs to be saved in case of not being cracked after 7 days. Your submission is cracked when your program has been outgolfed (whether it is by 1 byte or more).
For example, if the task you chose was to perform 2 × n, this could be a valid submission (in Python 2):
Python 2, 16 bytes, score = 15 / 16 = 0.9375
print(2*input())
Computes A005843, (offset = 0).
If your submission has been cracked, then you need to state that in your header like so:
Python 2, 16 bytes, score = 15 / 16 = 0.9375, [cracked] + link
print(2*input())
Computes A005843, (offset = 0).
Offset
This can be found on every OEIS page. For example, for A005843, the offset is 0,2
. We only need to use the first one, which is 0
. This means that the function is defined for all numbers ≥ 0.
In other words, the function OEIS(n) starts with n = 0. Your program needs to work for all cases given by OEIS.
More information can be found here.
Scoring
The score you get for your submission is equal to the following formula:
Score = Length (in bytes) of secret code ÷ Length (in bytes) of public code
The example above has the score 15 ÷ 16 = 0.9375.
The submission with the lowest score wins. Only submissions that have posted their solution will be eligible for winning.
Rules
- The task you need to do is an OEIS sequence of your choice.
- Given n, output OEIS(n). Deviation is not allowed, so you need to produce the exact same sequence (when given n, you need to output OEIS(n)).
- Submissions that are not cracked within a period of 7 days are considered safe after the solution has been posted (submissions older than 7 days that do not have their solution posted are still vulnerable in being cracked).
- In your submission, you need to post the following things: language name, byte count, full code, so no pastebin links etc. (to prevent answers like Unary), OEIS sequence, score with lengths of both programs and additionally, the encoding that is used.
- Note: the same sequence cannot be posted twice in the same language. (For example, if the sequence A005843 has been done in Pyth, you cannot use Pyth again for that same sequence.)
- Input and output are both in decimal (base 10)
Leaderboard
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><style>table th,table td{padding: 5px;}th{text-align: left;}.score{text-align: right;}table a{display: block;}.main{float: left;margin-right: 30px;}.main h3,.main div{margin: 5px;}.message{font-style: italic;}#api_error{color: red;font-weight: bold;margin: 5px;}</style> <script>QUESTION_ID=88979;var safe_list=[];var uncracked_list=[];var n=0;var bycreation=function(x,y){return (x[0][0]<y[0][0])-(x[0][0]>y[0][0]);};var byscore=function(x,y){return (x[0][1]>y[0][1])-(x[0][1]<y[0][1]);};function u(l,o){jQuery(l[1]).empty();l[0].sort(o);for(var i=0;i<l[0].length;i++) l[0][i][1].appendTo(l[1]);if(l[0].length==0) jQuery('<tr><td colspan="3" class="message">none yet.</td></tr>').appendTo(l[1]);}function m(s){if('error_message' in s) jQuery('#api_error').text('API Error: '+s.error_message);}function g(p){jQuery.getJSON('//api.stackexchange.com/2.2/questions/' + QUESTION_ID + '/answers?page=' + p + '&pagesize=100&order=desc&sort=creation&site=codegolf&filter=!.Fjs-H6J36w0DtV5A_ZMzR7bRqt1e', function(s){m(s);s.items.map(function(a){var he = jQuery('<div/>').html(a.body).children().first();he.find('strike').text('');var h = he.text();if (!/cracked/i.test(h) && (typeof a.comments == 'undefined' || a.comments.filter(function(b){var c = jQuery('<div/>').html(b.body);return /^cracked/i.test(c.text()) || c.find('a').filter(function(){return /cracked/i.test(jQuery(this).text())}).length > 0}).length == 0)){var m = /^\s*((?:[^,;(\s]|\s+[^-,;(\s])+).*(0.\d+)/.exec(h);var e = [[n++, m ? m[2]-0 : null], jQuery('<tr/>').append( jQuery('<td/>').append( jQuery('<a/>').text(m ? m[1] : h).attr('href', a.link)), jQuery('<td class="score"/>').text(m ? m[2] : '?'), jQuery('<td/>').append( jQuery('<a/>').text(a.owner.display_name).attr('href', a.owner.link)) )];if(/safe/i.test(h)) safe_list.push(e);else uncracked_list.push(e);}});if (s.items.length == 100) g(p + 1);else{var s=[[uncracked_list, '#uncracked'], [safe_list, '#safe']];for(var i=0;i<2;i++) u(s[i],byscore);jQuery('#uncracked_by_score').bind('click',function(){u(s[0],byscore);return false});jQuery('#uncracked_by_creation').bind('click',function(){u(s[0],bycreation);return false});}}).error(function(e){m(e.responseJSON);});}g(1);</script><link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/Sites/codegolf/all.css?v=7509797c03ea"><div id="api_error"></div><div class="main"><h3>Uncracked submissions</h3><table> <tr> <th>Language</th> <th class="score">Score</th> <th>User</th> </tr> <tbody id="uncracked"></tbody></table><div>Sort by: <a href="#" id="uncracked_by_score">score</a> <a href="#" id="uncracked_by_creation">creation</a></div></div><div class="main"><h3>Safe submissions</h3><table> <tr> <th>Language</th> <th class="score">Score</th> <th>User</th> </tr> <tbody id="safe"></tbody></table></div>
Note
This challenge is finished. The final winner is feersum with his Seed answer. Congratulations! :).
You can still submit new cops, but be aware that they are no longer competing.
Do I understand the rules right that if I come up with a 30-byte program and post a 40-byte program, someone who writes a 39-byte program couns as cracking it? – xnor – 2016-08-06T11:01:24.603
@xnor Yes, that is correct – Adnan – 2016-08-06T11:02:01.513
2@Andan That seems unfortunate. Say I write a golf with multiple clever tricks that improve on the obvious formula. If I post the obvious formula, anyone can find one improvement and win. Or, I have to tip my hand and give away all the improvements but one. Would you consider changing this, if it's not too late? Sorry for not thinking of this in this sandbox, I only noticed when trying the challenge in earnest. – xnor – 2016-08-06T11:07:38.293
4@xnor Hmm, that would cause a big problem with the scoring mechanism. You can then make an arbitirarily large submission and an almost impossible short one, and win the challenge. – Adnan – 2016-08-06T11:12:58.757
3@Adnan You could solve that by defining score = len(secret code)/min {len(public code), len(shortest code posted by robbers)}. – Anders Kaseorg – 2016-08-06T12:22:09.823
1@AndersKaseorg The score doesn't count if a robber has cracked your submission. – Adnan – 2016-08-06T12:25:38.987
3@Adnan The context is xnor’s suggestion to make the score count if the robbers beat your public score but do not match your secret score. I’m proposing a way to make that work while avoiding the problem you’re concerned about. – Anders Kaseorg – 2016-08-06T12:43:59.170
If someone cracks my submission, but hasn't found the shortest possible program (the intended solution), can I update the post with a shorter version? – xsot – 2016-08-06T14:12:49.477
@xsot I'm going to say no, because that would fall under the last rule of the challenge. – Adnan – 2016-08-06T14:28:44.317
@AndersKaseorg I'm pretty sure that goes against the rules of a [tag:cops-and-robbers] challenge. That means that you can easily win the challenge by simply submitting a lot of entries. – Adnan – 2016-08-06T14:32:27.913
3Yeah, finally another Cooooops and Rooooobbbbbers challenge. – insertusernamehere – 2016-08-06T20:41:59.860
If you can golf it any further (public or a secret) could you change the answer? – Blue – 2016-08-07T08:34:01.800
@muddyfish In chat, we have decided that you can golf your private answer before you reveal it. Your public answer must remain the same. – Adnan – 2016-08-07T09:23:12.867
@DerpfacePython For all terms given at OEIS when you press on list after the sequence. (Like this)
– Adnan – 2016-08-08T11:46:38.617Would it be acceptable to use my new language, Woefully?
– Destructible Lemon – 2016-09-07T06:18:25.857@DestructibleWatermelon You can use it, however it won't be competing since the language postdates the challenge. – Adnan – 2016-09-07T07:29:54.070
._. well, does the person who cracks it get points? – Destructible Lemon – 2016-09-07T07:30:45.460
@DestructibleWatermelon Yes, the cracker does receive the points. – Adnan – 2016-09-07T07:31:28.057