73
\$\begingroup\$

This is the cop's thread of a challenge. You can view the robber's thread here

A pretty common beginner style question is to print some string, but there's a catch! You need to do it without using any of the characters in the string itself!

For this challenge, we will find out who is the best at printing X without X. There are two threads to this, a cop's thread and a robber's thread.

In the cop's thread (this thread), users will choose a language (which we will call Y) and a string (which we will call X) and write a program in language Y which takes no input, and outputs exactly X without using any of the characters in X. The cop will then post both X and Y without revealing the program they have written.

Robbers will select the cop's answers and write programs in language Y which take no input and output X. They will post these "cracks" as answers in their thread. A crack need only work, not to be the intended solution.

Once a cop's answer is one week old, so long as it has not been cracked, the cop may reveal their program and mark it as "safe". Safe answers can no longer be cracked and are eligible for scoring.

Cops will be scored by length of X in characters with smaller scores being better. Only safe answers are eligible for scoring.

Extra Rules

You may be as specific or precise in choosing your language as you wish. For example you may say your language is Python, or Python 3, Python 3.9 (pre-release), or even point to a specific implementation. Robber's solutions need only work in one implementation of the given language. So, for example, if you say Python is your language, a robber's crack is not required to work in all versions of Python, only one.

Since command line flags and repls count as different languages, if your language is one of those then you should indicate that as at least a possible option for the language. For ease of use, I ask that you assume there are no command line flags in cases where command line flags are not mentioned.

You may choose to have your output as an error. If your intended solution does output as an error, you must indicate this in your answer.

Find Uncracked Cops

<script>site = 'meta.codegolf'; postID = 5686; isAnswer = false; QUESTION_ID = 207558;</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>

\$\endgroup\$
28
  • 1
    \$\begingroup\$ @user I believe errors are considered output, by our standard rules. I defer to those, so I believe the answer is yes. \$\endgroup\$
    – Wheat Wizard
    Jul 25, 2020 at 15:53
  • 1
    \$\begingroup\$ @SomoKRoceS You can use any characters. \$\endgroup\$
    – Wheat Wizard
    Jul 25, 2020 at 21:03
  • 4
    \$\begingroup\$ @Discretelizard I am not AdHocGarfHunter, but if your program does anything with the input (other than completely ignoring it), it is almost certainly invalid. \$\endgroup\$ Jul 26, 2020 at 15:09
  • 2
    \$\begingroup\$ @EthanChapman Program flags are considered different languages. I had not thought if this initially so I will update the question but I will say that in order for command line flags to be used they should be explicitly allowed, either a specific flag or flags in general (as per the language vagueness rules). \$\endgroup\$
    – Wheat Wizard
    Jul 26, 2020 at 15:23
  • 1
    \$\begingroup\$ @pppery Can the snippet deal with two submissions in a single post? Or should I make two answers and link them if I have a pair of highly related challenges? \$\endgroup\$ Jul 28, 2020 at 12:50

155 Answers 155

2
\$\begingroup\$

Javastack, score 11, round 10, Cracked by exedraj.

dfhklmquvx"

Game on... One more time.

Up-to-date copy of the interpreter

I spent all day working on this, so hopefully it holds up for at least 20 minutes...

\$\endgroup\$
1
  • \$\begingroup\$ no \$\endgroup\$
    – lyxal
    Aug 9, 2021 at 3:44
2
\$\begingroup\$

Javastack, score 8, round 12, Cracked by exedraj

kdhmujvf

No more alphabetical order for you, sunshine!

Probably the last one, unless an unintended crack is found.

Up-to-date copy of the interpreter, with ES2020 stuff removed

\$\endgroup\$
1
  • \$\begingroup\$ frick you \$\endgroup\$
    – lyxal
    Aug 9, 2021 at 5:58
2
\$\begingroup\$

Javastack, score 9, round 13, Cracked by exedraj

kdsmujvfb

No more constants for you (except numbers and strings, so not really, but whatever)

Probably the last one, unless an unintended crack is found.

Up-to-date copy of the interpreter, with ES2020 stuff removed

I admit defeat.

My basic idea for rounds 11-13 was that you could use replace to concatenate two values with something like "string1" "string2" "xy" swap "y" swap replace swap "x" swap replace, replacing the x with string1 and the y with string2.

exedraj managed to get around this in round 11 because I had put the result in alphabetical order, so chars could just be removed from the ascii constant. This was exploited more in round 12, so I created this one and replaced ascii with char. However, this was exploited even easier.

exedraj's trick was to wrap the stack, stringify, and remove commas. I couldn't bypass this because even if I removed w, they could use pair pair pair pair pair etc for effectively the same result, and I needed all the chars in pair.

So, that's it for now.

\$\endgroup\$
1
2
\$\begingroup\$

Vyxal, score 250, cracked properly by Aaroneous


 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVXYZ[\]^_`abcdefghijmnopqrtuvwxyz{|}~¡¢£¤¥¦§¨«¬¯°±²µ¶¹»¼½¾×Þßæð÷øĊċėĠġİĿŀŻżƈƒƛǍǎǏǐǑǒǓǔȦȧȮȯɖɽɾʀʁΠβελτḂḃḊḋḞḟḢḣḭṀṁṄṅṖṗṘṙṠṡṪṫẆẇẊẋẎẏ‛„‟†‡•…‹›⁋⁰⁺⁼⁽₀₁₂₄₅₆₇₈₌₍€₴℅⅛←↑→↓↔↲↳↵⇧⇩∆∇∑√∞∧∨∩∪∴∵∷≈≠≤≥≬⊍⋎⋏⌈⌊⌐□⟇⟑⟨⟩꘍ꜝ

Frick you with your bullcrap inf. That stops now. No more inf. (at least, not easily).

Edit: It took us a while, but we finally got there. Aaron got my intended solution 100%.

\$\endgroup\$
1
2
\$\begingroup\$

JavaScript (V8), score 20

[+`'"cv-0123456789*]

Good luck! This could be quite easy or quite hard.

\$\endgroup\$
1
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – m90
    Nov 7, 2021 at 5:56
1
\$\begingroup\$

Befunge-98 (FBBI), Score: 2, Cracked

Not too difficult, but I don't think this can be made harder in Befunge.

=,

My solution:

4b*:d0p'<1+1k @

\$\endgroup\$
1
1
\$\begingroup\$

Perl 5 + -p, Score: 30, Cracked

Outputs to STDOUT. Perl has so many ways to generate chars so I've probably missed a few alternative cracks, but here goes...

"'/0123456789<CMFQSV\^cmpqsv|~
\$\endgroup\$
1
1
\$\begingroup\$

Python 2, score 26 Cracked

[2517630984, '\\`"a_put']

The same as the output of this program.


This may well get cracked fairly quickly so apologies in advance if I am not around promptly to acknowledge it!

\$\endgroup\$
6
  • \$\begingroup\$ This can probably be cracked via the unicode tricks used in the most-upvoted robbers answer. \$\endgroup\$ Jul 27, 2020 at 3:23
  • 1
    \$\begingroup\$ @mypronounismonicareinstate In Python 2? \$\endgroup\$ Jul 27, 2020 at 3:24
  • \$\begingroup\$ I haven't tried and do not know when that "feature" was introduced, so I may be wrong. \$\endgroup\$ Jul 27, 2020 at 3:25
  • 3
    \$\begingroup\$ @mypronounismonicareinstate python.org/dev/peps/pep-3131 - introduced in 3.0 \$\endgroup\$ Jul 27, 2020 at 3:26
  • 1
    \$\begingroup\$ Cracked \$\endgroup\$
    – Sisyphus
    Jul 27, 2020 at 4:17
1
\$\begingroup\$

Java, Score: 2 (Cracked)

Output (X):

.

(a dot and a newline)

Never golfed before, but saw this and couldn't resist trying; probably will be cracked within the hour, considering it's not really that complicated. My intended solution output to standard error.

\$\endgroup\$
5
  • 1
    \$\begingroup\$ Welcome to the site! Cracked, although it probably wasn't what you were intending. \$\endgroup\$
    – nthistle
    Jul 27, 2020 at 1:31
  • 1
    \$\begingroup\$ For reference, there was a previous Java answer (now removed) by @user that used the Unicode character escaping trick -- you're probably going to have to include numbers, backslash, or 'u' in the answer in order to prevent this. Also, the newline doesn't make it any harder, since in Java you can just remove all newlines without affecting anything. \$\endgroup\$
    – nthistle
    Jul 27, 2020 at 1:34
  • 2
    \$\begingroup\$ Never knew about that Unicode trick, should've looked up whether something like that was possible before posting. The newline was more a side-effect of the way I did it than actually intended to make it difficult. You're correct, that's pretty different from my solution. Am I allowed to repost/edit with a modified version that patches previous cracks? \$\endgroup\$
    – MCross
    Jul 27, 2020 at 1:40
  • 1
    \$\begingroup\$ I think you can repost a modified version \$\endgroup\$
    – user
    Jul 27, 2020 at 1:58
  • 2
    \$\begingroup\$ As the OP for the question I back up user's claim. You are free to post a modified version. Other's (including me) have already done that. Good luck! \$\endgroup\$
    – Wheat Wizard
    Jul 27, 2020 at 2:02
1
\$\begingroup\$

Perl 5, Score: 35, Cracked

"'/0123456789<CMPQSTVY\^`cmpqstvy|~

Foiled in my last attempt I'll try another more restrictive set...

\$\endgroup\$
2
  • \$\begingroup\$ Cracked \$\endgroup\$ Jul 27, 2020 at 14:04
  • \$\begingroup\$ @Gilles'SO-stopbeingevil' Nice work! I've got one last attempt to share but will have to be a much higher score! \$\endgroup\$ Jul 27, 2020 at 16:45
1
\$\begingroup\$

Javascript (Browser), Score: 34. cracked

ABDEFGHIJKLMNOPQRTUVWXYZ1234567890

Shouldn't be too hard compared to the other ones.

\$\endgroup\$
2
  • \$\begingroup\$ Welcome to the site! I've slightly edited your answer to fit the standard format used around here. Good luck, and hope you don't get cracked! \$\endgroup\$ Jul 27, 2020 at 21:20
  • \$\begingroup\$ Cracked \$\endgroup\$
    – nthistle
    Jul 27, 2020 at 23:38
1
\$\begingroup\$

Javascript (Browser), Score: 27 Cracked

ABDEFGINOPQTUVYZ234567890tf[

\$\endgroup\$
4
  • \$\begingroup\$ Cracked \$\endgroup\$
    – Bubbler
    Jul 28, 2020 at 0:34
  • \$\begingroup\$ If you're intending to submit a third cop answer with "ABDEFGINOPGTUVYZ234567890tf[evalsic", please do so as a separate answer. \$\endgroup\$ Jul 28, 2020 at 3:27
  • \$\begingroup\$ ok. sure (stuff to fill the required characters) \$\endgroup\$ Jul 28, 2020 at 5:02
  • \$\begingroup\$ Brony? Greetings (My username is formerly TwilightSparkle) \$\endgroup\$ Jul 28, 2020 at 13:26
1
\$\begingroup\$

Javascript, score 6, Cracked

(\SuC)

Alright, added 3 more characters. Same concept as before, but harder this time.

My solution:

[]["fill"]["constr"+[[][0]+[]][0][0]+"ctor"]`a${[]["fill"]["constr"+[[][0]+[]][0][0]+"ctor"]`a${"ret"+[[][0]+[]][0][0]+"rn "+[[][0]+[]][0][0]+"nescape"}````console.log%28"%28%5c%5c%53%75%43%29"%29`}```

\$\endgroup\$
1
1
\$\begingroup\$

Java, score 2 Cracked

yC\

This is supposed to be printed to stdout. The y doesn't let you use System.out.println, the \ is so you don't use Unicode escapes, and the C is so you don't use reflection. This isn't super hard - I found it with my first Google search to make an answer to this question.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Cracked \$\endgroup\$
    – nthistle
    Jul 27, 2020 at 22:58
1
\$\begingroup\$

Ruby, Score: 9, Cracked

.'"?%([:<

My code outputs with no trailing newline and works for Ruby 1.8.7 onwards. By design, string creation is difficult.

Edit: I've posted a new version hardened against the weaknesses found by @DomHastings and @Gilles'SO-stopbeingevil'. Because my code is almost unchanged I'll hold off on revealing it.

\$\endgroup\$
6
  • \$\begingroup\$ Cracked although I imagine this wasn't your intention... \$\endgroup\$ Jul 30, 2020 at 17:09
  • \$\begingroup\$ @DomHastings Most definitely not! But isn't that Ruby + Bash? \$\endgroup\$
    – Dingus
    Jul 30, 2020 at 19:48
  • \$\begingroup\$ Hmmm, yeah, I guess. Thought I was pushing it a little... \$\endgroup\$ Jul 30, 2020 at 19:59
  • 1
    \$\begingroup\$ Using a shell escape works on Ruby on any POSIX platform, and the challenge allows cracks that only work on a specific implementation. So it's legit. Cc @DomHastings Dom's solution is a bit iffy because it requires bash, not just any POSIX platform, so it's a constraint on the presence of an external tool and not just a choice of implementation. \$\endgroup\$ Jul 30, 2020 at 22:51
  • 1
    \$\begingroup\$ If you push an updated challenge that forbids backquote, be sure to also arrange to forbid putc which prints character by their numerical value. \$\endgroup\$ Jul 30, 2020 at 23:00
1
\$\begingroup\$

Part 2: PicoLisp, score: 18 cracked

Segmentation fault

or (similar):

Segmentation fault (core dumped)

(output to STDERR)

A bit harder than my previous answer. . .

\$\endgroup\$
11
  • \$\begingroup\$ Would this be considered a crack? The output shown there is correct (assuming it's been reproduced accurately), but running on TIO produces leading and trailing garbage. \$\endgroup\$
    – Dingus
    Jul 30, 2020 at 11:30
  • 1
    \$\begingroup\$ @Dingus Almost, but that has spaces (it seems to work ). If it produces a Segmentation fault it's fine (with or without garbage) because if you run it as pil file.l it won't create garbage. If in doubt, see if you can install picolisp. \$\endgroup\$
    – Wezl
    Jul 30, 2020 at 13:13
  • \$\begingroup\$ Ah yeah right... I completely overlooked the spaces! Segfaults without them too, though. \$\endgroup\$
    – Dingus
    Jul 30, 2020 at 13:25
  • \$\begingroup\$ The output I get from pil for a space-free version of the code is Segmentation fault (core dumped). Not sure this is valid. Even if you allow the (core dumped) bit, my code contains both ( and )... \$\endgroup\$
    – Dingus
    Jul 30, 2020 at 13:36
  • 2
    \$\begingroup\$ I can't reproduce this. When picolisp segfaults on my machine, it doesn't print anything, it just segfaults. If you're running it from a shell, the shell may print a message (depending on how it's configured, the locale, etc.), but this message does not come from the program. If the intended solution was to make it segfault, this is invalid for the challenge. \$\endgroup\$ Jul 30, 2020 at 22:46
1
\$\begingroup\$

><>, score: 17 - Cracked

0123456789abcdefo

I'm going to ban you from using numbers, too! What can you do now?!

\$\endgroup\$
3
  • \$\begingroup\$ That's just rude and mildly inconvenient. :P \$\endgroup\$
    – lyxal
    Aug 12, 2020 at 6:44
  • \$\begingroup\$ @Lyxal So can you crack it? (It's not hard to anyone familiar with ><>.) \$\endgroup\$ Aug 12, 2020 at 6:45
  • \$\begingroup\$ It was extremely inconvenient, but cracked lol \$\endgroup\$
    – lyxal
    Aug 12, 2020 at 7:28
1
\$\begingroup\$

><>, score: 19

0123456789abcdeflol

I could've made it 18 but just for the lols

\$\endgroup\$
1
1
\$\begingroup\$

PHP, Score: 1 Cracked

?

No command line flags were used.

\$\endgroup\$
1
1
\$\begingroup\$

PHP7, score: 15 (Cracked)

funtim(){}_=/\~
\$\endgroup\$
1
1
\$\begingroup\$

Setanta, score 3, cracked by Dingus

Probably an easy one.

N I

Here's my solution:

n:=go_téacs(go_uimh("!"))[0]sp:=go_téacs(gníomh(a){})[1]i:=go_teacs(eas@mata(1000))[0]scríobh(n+sp+i)
\$\endgroup\$
1
  • \$\begingroup\$ Cracked \$\endgroup\$
    – Dingus
    Aug 31, 2020 at 5:08
1
\$\begingroup\$

AlphaBeta, score: 12, Cracked

abcdefghijkl

I think this will get cracked quick, but I can't come up with anything else for AlphaBeta.

\$\endgroup\$
1
  • \$\begingroup\$ Cracked \$\endgroup\$
    – Dingus
    Nov 6, 2020 at 9:53
1
\$\begingroup\$

LUA 5.1, Score: 22, Cracked

Output

0123456789 "#$&'*+-/\a

\$\endgroup\$
1
  • \$\begingroup\$ Cracked \$\endgroup\$
    – Dingus
    Feb 7, 2021 at 13:01
1
\$\begingroup\$

Gforth, 3 bytes

    

(That's a space, followed by a tab, followed by a newline)

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Cracked using a vertical tab. \$\endgroup\$
    – EasyasPi
    Feb 9, 2021 at 17:31
1
\$\begingroup\$

x86 Assembly (gcc, Linux), score: 8, safe

Here is one for you x86 programmers.

Textual assembly, 32-bit x86 Linux.

RrL%ljJ.

Your dilemma:

  • You can't use any assembler directives because . is banned.
    • You are stuck in AT&T syntax
    • You can't hand-encode instructions with .byte, .asciz, etc.
  • Because you lack %, it is impossible to use anything that refers to registers.
  • You have libc, but since you can't use CALL, JMP, Jcc, LOOP or RET, it is impossible to use.
  • You can still INT $0x80, but since you can't refer to registers, it is impossible to set up.

If you didn't already hate AT&T syntax, you definitely will now. 😈

The header to define the function is provided for you, as well as a template on TIO.

        # String to print (w/o quotes):
        #    "RrL%ljJ."
        # 32-bit Linux, glhf
        # theb  $est(%syntax),%ever
        .att_syntax prefix
        .globl main
main:

TIO template

I actually wanted this to be cracked so I can post an eviler one, but whatever.

My solution: Try it online!

\$\endgroup\$
1
\$\begingroup\$

ARM Assembly (GAS, Linux, no libc), score: 7, safe

Textual assembly, not machine code.

bpsBPS.

This makes it so you can't use bx, bl blx, push, pop, svc, swi, str, stm, syscall, mrs, or any assembler directives. Good luck trying to run a syscall or switch to Thumb. 😈

You can assume your code is placed under this exact header, so don't worry about declaring the function.

        .text
        .arch armv5te
        .arm
        .globl _start
_start:

Should be pretty easy for those who are familiar with ARM's assembler. 🙂

My solution I can't get code blocks to work properly in spoilers, so here's a GitHub gist.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Code blocks in spoilers can be made by prepending the first line of code with >!<pre><code>, prepending all subsequent lines with >!, and appending </code></pre> to the last. Example: if your code was a\nb\nc\nd\ne (with \n being a newline, of course; I can't put newlines in comments so this is the closest equivalent), you would type >!<pre><code>a\n>!b\n>!c\n>!d\n>!e</code></pre> (once again, with \n being a newline). \$\endgroup\$
    – Makonede
    Feb 3, 2021 at 23:08
1
\$\begingroup\$

Rattle, Score: 35, Cracked

p
-
;
16.0112.01568.03136.021952.0

Note that there should be a trailing newline (technically it's impossible to do it without the trailing newline).

This should be relatively easy to crack...

As it's been cracked, here's my implementation - feel free to try to solve this a different way and teach yourself the language!

7|s[+]`b*~,b*~*b*b*~b=+++++++++++++++++++++++++++++++++++++++++++++,++++++++++++++,

There is an online interpreter available here - all you need to do is replace what's in the "code" section and hit run (I would recommend minimising the header and footer as well). Do not modify the interpreter code (i.e. don't touch the Python code in the header and footer).

Good luck!

Edit

I'm deciding to give out a small hint - try playing around with functions without arguments! Some functions have default values

\$\endgroup\$
8
  • \$\begingroup\$ @EasyasPi I screwed up markdown, thanks for pointing this out. I'll edit it real quick \$\endgroup\$
    – Daniel H.
    Feb 11, 2021 at 3:29
  • \$\begingroup\$ I assume this is a loophole, right?. (Interpreter code snipped because bitly hates me) 😏 \$\endgroup\$
    – EasyasPi
    Feb 11, 2021 at 4:25
  • \$\begingroup\$ @EasyasPi yes, that is a loophole... I guess I should sanitise my inputs in the next update! Definitely a creative answer though! \$\endgroup\$
    – Daniel H.
    Feb 11, 2021 at 4:28
  • \$\begingroup\$ @EasyasPi it looks like your answer still uses - though \$\endgroup\$
    – Daniel H.
    Feb 11, 2021 at 4:29
  • 1
    \$\begingroup\$ I count only 35 bytes (including the trailing newline). Are there unprintable characters hiding in there? \$\endgroup\$
    – Dingus
    Feb 11, 2021 at 4:34
1
\$\begingroup\$

Lua 5.1, Score: 35 Cracked

Output

 !"#$&'*+-./:;<=>?@GaLl\`0123456789
\$\endgroup\$
3
  • \$\begingroup\$ I count only 35 characters. Has SE gobbled an unprintable? \$\endgroup\$
    – Dingus
    Feb 10, 2021 at 10:46
  • \$\begingroup\$ Nope, you're right, its my bad. fixed \$\endgroup\$
    – LuaNoob
    Feb 10, 2021 at 16:26
  • \$\begingroup\$ Cracked \$\endgroup\$
    – Dingus
    Feb 10, 2021 at 21:51
1
\$\begingroup\$

Lua 5.1, Score: 50 Cracked

Output

     !"#$%&'*+-./0123456789:;<=>?@G\^`ajklmpqvxyz{|}

Thats a TAB and SPACE at the beginning and a new line at the end. My code to produce that is 19542 bytes long in just 1 line. Thats my last try, cause once you come behind this you can come behind everything in LUA in this Thread.

Have fun :-)

\$\endgroup\$
1
  • \$\begingroup\$ Cracked. Only 5152 bytes so I guess it's not your intended solution. \$\endgroup\$
    – Dingus
    Feb 13, 2021 at 3:23
1
\$\begingroup\$

YaBASIC, Score:13 Cracked by Dingus

X: The string to crack:

0
1
2
3
4
5
6
7
8
9
A
a
-

The language may be Basic, but is the solution?

Y: The language - YaBASIC:

print "Can you crack it?"

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – Dingus
    Mar 1, 2021 at 12:50
  • \$\begingroup\$ @Dingus - OK, you got it pretty quick! That's a good solution actually. Give me a sec and I'll post a harder version for you if you're interested. \$\endgroup\$ Mar 1, 2021 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.