67
\$\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\$
    – Grain Ghost
    Jul 25 '20 at 15:53
  • 1
    \$\begingroup\$ @SomoKRoceS You can use any characters. \$\endgroup\$
    – Grain Ghost
    Jul 25 '20 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 '20 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\$
    – Grain Ghost
    Jul 26 '20 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 '20 at 12:50

149 Answers 149

1
\$\begingroup\$

05AB1E, Score: 1, Cracked

X = .

I think it is an easy one :)

edit

Cracked by @nthistle

My approach (without using ASCII code to char conversion):

98/γ¦ć

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Cracked \$\endgroup\$
    – nthistle
    Jul 25 '20 at 20:58
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 '20 at 3:23
  • 1
    \$\begingroup\$ @mypronounismonicareinstate In Python 2? \$\endgroup\$ Jul 27 '20 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 '20 at 3:25
  • 3
    \$\begingroup\$ @mypronounismonicareinstate python.org/dev/peps/pep-3131 - introduced in 3.0 \$\endgroup\$ Jul 27 '20 at 3:26
  • 1
    \$\begingroup\$ Cracked \$\endgroup\$
    – Sisyphus
    Jul 27 '20 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 '20 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 '20 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 '20 at 1:40
  • 1
    \$\begingroup\$ I think you can repost a modified version \$\endgroup\$
    – user
    Jul 27 '20 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\$
    – Grain Ghost
    Jul 27 '20 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 '20 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 '20 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 '20 at 21:20
  • \$\begingroup\$ Cracked \$\endgroup\$
    – nthistle
    Jul 27 '20 at 23:38
1
\$\begingroup\$

Javascript (Browser), Score: 27 Cracked

ABDEFGINOPQTUVYZ234567890tf[

\$\endgroup\$
4
  • \$\begingroup\$ Cracked \$\endgroup\$
    – Bubbler
    Jul 28 '20 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 '20 at 3:27
  • \$\begingroup\$ ok. sure (stuff to fill the required characters) \$\endgroup\$ Jul 28 '20 at 5:02
  • \$\begingroup\$ Brony? Greetings (My username is formerly TwilightSparkle) \$\endgroup\$
    – null
    Jul 28 '20 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 '20 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 '20 at 17:09
  • \$\begingroup\$ @DomHastings Most definitely not! But isn't that Ruby + Bash? \$\endgroup\$
    – Dingus
    Jul 30 '20 at 19:48
  • \$\begingroup\$ Hmmm, yeah, I guess. Thought I was pushing it a little... \$\endgroup\$ Jul 30 '20 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 '20 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 '20 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 '20 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 '20 at 13:13
  • \$\begingroup\$ Ah yeah right... I completely overlooked the spaces! Segfaults without them too, though. \$\endgroup\$
    – Dingus
    Jul 30 '20 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 '20 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 '20 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 '20 at 6:44
  • \$\begingroup\$ @Lyxal So can you crack it? (It's not hard to anyone familiar with ><>.) \$\endgroup\$
    – null
    Aug 12 '20 at 6:45
  • \$\begingroup\$ It was extremely inconvenient, but cracked lol \$\endgroup\$
    – lyxal
    Aug 12 '20 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 '20 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 '20 at 9:53
1
\$\begingroup\$

LUA 5.1, Score: 22, Cracked

Output

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

\$\endgroup\$
1
  • \$\begingroup\$ Cracked \$\endgroup\$
    – Dingus
    Feb 7 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 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 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 at 3:29
  • \$\begingroup\$ I assume this is a loophole, right?. (Interpreter code snipped because bitly hates me) 😏 \$\endgroup\$
    – EasyasPi
    Feb 11 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 at 4:28
  • \$\begingroup\$ @EasyasPi it looks like your answer still uses - though \$\endgroup\$
    – Daniel H.
    Feb 11 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 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 at 10:46
  • \$\begingroup\$ Nope, you're right, its my bad. fixed \$\endgroup\$
    – LuaNoob
    Feb 10 at 16:26
  • \$\begingroup\$ Cracked \$\endgroup\$
    – Dingus
    Feb 10 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 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 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 at 12:54
1
\$\begingroup\$

Dis, Score: 1, cracked by Dingus

{

I have never thought of constructing the program when I posted this.

PS. Rule clarification.

  • Output exactly a character whose codepoint is 123 in decimal integer.
  • Do not output else.
  • Then terminate the program.
  • No Dis implementation whose { command does putchar(codepoint of (a%256)) rather than putchar(codepoint of a); if your implementation is so, reguster A must be exactly 123 when { is executed. deleted as reference implementation, implemented in C, uses putchar(char) and char stores eight octets (maybe not on some machines).

Intended solution

*|||*__>*__>_||^___________________________*!**}}*! Try it online! Link to my interpreter, with comments. This uses that 123=11120t=1-11122t-11122t. To produce 1 I had to make 00100t first by 0-01020t-01120t-01120t. Then I did it > twice.

\$\endgroup\$
6
  • \$\begingroup\$ PS. I've just completed my program. \$\endgroup\$ Jul 18 at 7:47
  • \$\begingroup\$ I don't follow the last bullet point: why does it matter how the { command is implemented? You say 'when { is executed', but { can't be executed in this challenge. \$\endgroup\$
    – Dingus
    Jul 20 at 14:19
  • \$\begingroup\$ @Dingus; 1. Did I misread the specification? I couldn't see the specification that it outputs A modulo 256; or is it implicitly specified by reference implementation? 2. Outputting that character without using the character in your program is the point of my challenge. \$\endgroup\$ Jul 20 at 22:19
  • \$\begingroup\$ I agree that the goal is to print { without using {, and that's the root of my question. If you can't use { to begin with, I don't understand the intent behind the last bullet point. Why does it matter how { behaves (mod 256 or not) if you can't use it? \$\endgroup\$
    – Dingus
    Jul 21 at 2:30
  • \$\begingroup\$ @Dingus Deleted final bullet. \$\endgroup\$ Jul 21 at 10:59
1
\$\begingroup\$

Javastack, score 10, Cracked by exedraj

1234567890

Have fun ;}

My intended solution will not be posted here.

\$\endgroup\$
1
  • \$\begingroup\$ crackèd \$\endgroup\$
    – lyxal
    Aug 7 at 4:14
1
\$\begingroup\$

Javastack, score 13, Cracked again by exedraj

1234567890"nq

Have more fun ;}

To exedraj: HR couldn't modify ><> :)

\$\endgroup\$
1
  • \$\begingroup\$ Roses are red, I did this kind of cracking comment last time, this answer is cracked, so you'll have to post a new challenge for another rhyme \$\endgroup\$
    – lyxal
    Aug 7 at 6:48
1
\$\begingroup\$

Javastack, score 14, Cracked by exedraj - on to round 4!

1234567890"dqw

No add, no duplicate, no double, no random, no power - hopefully this will thoroughly bamboozle you.

Have fun!

I gave you back flatprint - you're gonna need it.

\$\endgroup\$
1
  • \$\begingroup\$ Ur a sussy baka because I cronked this \$\endgroup\$
    – lyxal
    Aug 7 at 11:17
1
\$\begingroup\$

Javastack, score 15, Cracked by exedraj

1234567890"crsy

Game on, again.

Up-to-date copy of the interpreter

\$\endgroup\$
1
  • \$\begingroup\$ yesn't \$\endgroup\$
    – lyxal
    Aug 8 at 0:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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