62
10
Inspired by this comment...
Thanks to users Step Hen, Wheat-Wizard, and Dennis for helping my solidify the specification of this challenge before posting it!
This is the Cops' thread. For the Robbers' thread, go here
In this challenge, you are tasked with running some code that makes it so that your language no longer satisfies our criteria of being a programming language. In that challenge, that means making it so that the language can no longer...
Take numerical input and output
Add two numbers together
Test if a certain number is a prime or not.
This is a cops-and-robbers challenge, where there are two different challenges with two different objectives: the Cops will try to write some code that makes the language mostly unusable, and the robbers will try to find the hidden workaround that allows the cops to recover their language.
As a cop, you must write two snippets of code:
One that makes your language mostly unusable, e.g. by removing built-in functions for taking input/output and numerical operations. The more features you remove, the better. This code is not allowed to crash or exit. It should be possible to add code to the end of this snippet, and that code will get evaluated. And...
...a snippet of code that takes two non-negative integers as input, adds them together, and outputs their sum. This snippet must still correctly function even after running the first snippet. When the two snippets are combined together, they must form a full program that adds two numbers, or define a function that adds two numbers. Ideally, this snippet should rely upon very obscure behavior, so as to be more difficult to find.
You may choose any standard method of input and output. However, you must reveal exactly which format (input and output) you are using. A robber cannot crack your answer unless they use the same format as you.
After writing both of these snippets, you must post the first one as an answer, without revealing the second one. Your answer should contain all of the following information:
The first snippet (obviously not the second).
Language (including minor version, since most submissions will probably rely on strange edge-cases)
IO format, including whether it's a function or full program. Robbers must use the same format for their crack to be valid.
Any strange edge cases required for your answer to work. For example, only runs on linux, or requires an Internet connection. Obviously, this is slightly subjective, but if a cop has some extreme edge case that prevents it from being cracked, and then only reveals this after being safe, I consider this poor sportsmanship. A potential robber should have all information necessary to crack your answer before it is cracked.
You do not need to reveal your byte count until your answer is safe.
Here's an example. For the first snippet, you could submit the following Python 3 program:
Python 3
print=None
Takes input from STDIN and output to STDOUT
And then as your second snippet, you could write:
import sys
a,b=int(input()),int(input())
sys.stdout.write(a+b)
This is valid because it will take two numbers as input, and output their sum even if you join the two snippets together, e.g.
print=None
import sys
a,b=int(input()),int(input())
sys.stdout.write(a+b)
However, this will be extremely easy for a robber to find a solution to. Since this would be very easy to crack, you could attempt to patch this particular approach like so:
import sys
sys.stdout=None
print=None
However, even this has a very easy workaround:
del print
a,b=int(input()),int(input())
print(a+b)
As a cop, your goal is to make the hidden workaround as obscure as possible, to prevent the robbers from finding it.
The robbers will look at one of your answers, and attempt to crack it. They may crack it by writing any valid snippet that could work as snippet 2 (adding two numbers together after the language is made mostly unusable). This does not have to be the same snippet as you originally intended. If a robber cracks your answer, they will leave a comment on your answer, and then you should edit it to indicate that it has been cracked. If your post is cracked, you should edit your answer to show the solution (snippet 2) that you originally intended. This isn't a rule per se, just a friendly suggestion to keep the game fun. You do not have to.
If an answer remains uncracked for one whole week, you can edit in your second snippet, and indicate that your answer is now safe. If you do not edit it after the week is up, other users can still crack it until you do. If you do not reveal your second snippet, you cannot claim points for your answer, or call it safe.
The winner of the cops' thread is the shortest safe answer including both snippets, counted in bytes, and this answer will be accepted after sufficient time has passed. You do not need to reveal your byte count until your answer is safe, since byte count is irrelevant to your score until your answer is safe. In the event that sufficient time has passed and no answers remain uncracked, the winner will be the answer that remained uncracked for the longest period of time.
Have fun!
Rule clarifications
The first snippet must run correctly without taking any input. It may output whatever you like, and this output will be ignored - as long as after the snippet is done, the second snippet runs correctly.
The second snippet must actually be executed for your answer to be valid. This means an answer like
import sys sys.exit()
is not valid because it doesn't break the language. It simply quits. Similarly, entering an infinite loop is not valid, since the second snippet will never be executed.
After being safe, your score is the byte count of both snippets.
This goes back to Please reveal any strange edge cases required for your answer to work... Your submission must contain enough information before being revealed to be reproducible after being revealed. This means that if your answer becomes safe, and then you edit in: Here's my answer. Oh ya, BTW this only works if you run it on Solaris, joke's on you! your answer is invalid and will be deleted and not considered eligible for winning.
The second snippet is allowed to crash after outputting the sum - as long as the output is still correct (for example, if you choose to output to STDERR, and then you get a bunch of crash information, this is invalid).
You may not edit your code after submitting an answer.
You may not rely on cryptographic functions like encryption, hash functions, CSPRNGs etc.
Snippet to find uncracked submissions:
<script>site='meta.codegolf';postID=5686;isAnswer=false;QUESTION_ID=133174;</script><script src='//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js'></script><script>jQuery(function(){var u='//api.stackexchange.com/2.2/';if(isAnswer)u+='answers/'+postID+'?order=asc&sort=creation&site='+site+'&filter=!GeEyUcJFJeRCD';else u+='questions/'+postID+'?order=asc&sort=creation&site='+site+'&filter=!GeEyUcJFJO6t)';jQuery.get(u,function(b){function d(s){return jQuery('<textarea>').html(s).text()};function r(l){return new RegExp('<pre class="snippet-code-'+l+'\\b[^>]*><code>([\\s\\S]*?)</code></pre>')};b=b.items[0].body;var j=r('js').exec(b),c=r('css').exec(b),h=r('html').exec(b);if(c!==null)jQuery('head').append(jQuery('<style>').text(d(c[1])));if (h!==null)jQuery('body').append(d(h[1]));if(j!==null)jQuery('body').append(jQuery('<script>').text(d(j[1])))})})</script>
3What should be done for languages like C? Concatenation only allows for one "main snippet", and any logic is going to have to go there. E.g., if I have
int main(){ do_evil_stuff(); }
where should the users code go? In a function? After all the statements inmain
? – Conor O'Brien – 2017-07-19T00:34:56.683@ConorO'Brien could employ some trick like commenting out the last
}
and inserting your own (in fact, that could be part of the challenge :P) – Stephen – 2017-07-19T01:41:42.093@StepHen You can't modify your own code in C, it's a compiled language – Conor O'Brien – 2017-07-19T01:47:30.767
What constitutes "run correctly"? – Conor O'Brien – 2017-07-19T01:51:24.750
1Can the second snippet be placed anywhere in the first snippet? – LegionMammal978 – 2017-07-19T02:51:31.470
1I know nothing about coding, but this challenge looks amazing, – Pritt Balagopal – 2017-07-19T14:04:57.977
@DJMcMayhem this answer was edited but to correct an issue that was unforeseen (the program was made... not a program). In the end I cracked it anyways and without that change having any effect. Does it still count?
– Olivier Grégoire – 2017-07-19T15:07:39.863This is essentially what I was going for in this sandbox proposal. I'll delete my proposal, since it was never posted.
– mbomb007 – 2017-07-19T21:25:28.6572
I edited in jimmy23013's awesome snippet. Feel free to revert, but I was using it myself anyway to find submissions and thought it might help others.
– Dom Hastings – 2017-07-20T18:13:46.7332@DomHastings That's extremely helpful! Thank you very much :) – James – 2017-07-20T18:14:35.920
This challenge has a suprisingly high percentage of answers being cracked ... – pppery – 2017-07-21T13:17:10.287