51
2
For the purpose of this challenge, we'll define whitespace as only linefeeds (0x0A) and spaces (0x20). Note that most languages and regex flavours consider many other characters as whitespace as well, both inside and outside the ASCII range so you might not be able to make use of the corresponding built-ins.
The Cops' Challenge
You should write a program or function in a language of your choice, which takes a string, consisting of ASCII (except NUL) characters, as input and outputs it with all whitespace removed. For example if you received the following input:
H e l l o,
W o r l d!
You should output
Hello,World!
Your submission will then be your source code with all whitespace removed (the same process as passing your solution as input to itself, although your solution may also contain characters outside the ASCII range). Your goal is to make it as hard as possible to figure out where whitespace needs to be inserted to recover a valid solution in your language of choice. Note that robbers may insert fewer whitespace than you removed, but not more. Also remember that robbers don't have to match your exact code, they just have to find any valid solution.
Your answer should contain the following:
- The language (and version if necessary) in which you wrote your solution.
- The byte count of your solution before removing whitespace.
- Your solution with whitespace removed.
Your solution may be either a program or function, but not a snippet and you must not assume a REPL environment. You may take input via STDIN, command-line argument or function argument and output via STDOUT, function return value or function (out) parameter.
In the interest of fairness, there must be a freely available interpreter or compiler for your chosen language.
You must not use built-ins for hashing, encryption or random number generation (even if you seed the random number generator to a fixed value). Your solution must be able to process any string of 100 characters or less in under 10 seconds on a reasonable desktop machine.
If your answer has not been cracked within 7 days (168 hours), you may reveal your own solution at which point your answer is considered safe. As long as you don't reveal your solution, it may still be cracked by robbers, even if the 7 days have already passed. The shortest safe answer wins (measured before removing whitespace).
If your answer does get cracked, please indicate this in the header of your answer, along with a link to the corresponding robber's answer.
Go here for the robbers' part.
Uncracked Submissions
<script>site = 'meta.codegolf'; postID = 5686; isAnswer = false; QUESTION_ID = 103182;</script><script src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js'></script><script>jQuery(function(){var u='https://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>
Related. (Inspiration, in fact.) – Martin Ender – 2016-12-14T19:34:00.987
7Seems like Whitespace would break this challenge... – NoOneIsHere – 2016-12-14T19:51:10.333
8@SeeOneRhino Why? The robber just has to solve the problem in Whitespace, not using more bytes than the cop. Unless a cop finds a crazily well-golfed Whitespace answer that no one can match, Whitespace answers are generally the most vulnerable in this challenge. – Martin Ender – 2016-12-14T19:53:05.440
I guess I misunderstood. I thought whitespace would do something strange... – NoOneIsHere – 2016-12-14T20:07:03.297
1@SeeOneRhino Also, tabs don't count as whitespace, so they wouldn't be removed. – mbomb007 – 2016-12-14T20:59:34.987
4No hexagony submissions this time, I guess – MildlyMilquetoast – 2016-12-15T00:03:33.610
If my language accepts input one character at a time (and outputs one character at a time as well), can I separate my input/output by lines? – Gabriel Benamy – 2016-12-15T14:46:55.403
@GabrielBenamy how would you represent linefeeds in that case? I don't see why reading input character by character would make the task a problem? – Martin Ender – 2016-12-15T14:48:13.273
When COW reads ASCII input, it reads the first character, stores its code point in memory, and then continues reading and discarding characters until it reaches a
\n
. So to represent a newline in your input, simply have two newlines in a row. – Gabriel Benamy – 2016-12-15T14:52:46.227@GabrielBenamy if that's the only way to represent an arbitrary string, I'm fine with it, but please state this in your answer. – Martin Ender – 2016-12-15T14:57:12.760
The snippet doesn't seem to do anything for me on Firefox, though it throws a "400 (Bad Request)" error on Chrome. – ETHproductions – 2016-12-15T16:08:37.607
It strikes me that a winning solution in PERL would be
using acme::Bleach;
followed by a bunch of whitespace, well golfed. Gives the robbers literally no information to go from! Anyone feel like coding that? – Cort Ammon – 2016-12-16T17:03:55.970