# Print X without X (cop's thread)

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 count as different languages, you should indicate specific command line flags or the possibility of command line flags as part of your 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>

• @user I believe errors are considered output, by our standard rules. I defer to those, so I believe the answer is yes. – Wheat Wizard Jul 25 '20 at 15:53
• @SomoKRoceS You can use any characters. – Wheat Wizard Jul 25 '20 at 21:03
• @Discretelizard I am not AdHocGarfHunter, but if your program does anything with the input (other than completely ignoring it), it is almost certainly invalid. – the default. Jul 26 '20 at 15:09
• @Discretelizard they have the requirement by default at Loopholes that are forbidden by default – the default. Jul 26 '20 at 15:43
• Given the large number of answers to this challenge, I suggest adding the uncracked answers stack snippet to the question body, so it's easier to find uncracked cops. (I'm posting a comment rather than adding it myself due to the rule against adding leaderboards) – pppery Jul 27 '20 at 23:14

# SimpleTemplate, Score: 7 Cracked

This is just a simple one for you.

It outputs the following characters to STDOUT:

cho0.84


Should be a bit easy to find a working solution for this.

As you've seen, it has been cracked.
The code posted is a lot more complicated than I had written:

{@set x "a"}{@set k "{@in\x63 by 2251 x}{@in\x63 by -1 x}"}{@eval k}{@print "#{x}#{VERSION}"}


Simply starts x with "a" and increments it 2251 times.
Incrementing goes from "a" to "z", then "aa" ... "zz", "aaa" ... "chp".
Then, it decrements once (increments by -1), which results in "cho".

The line {@print "#{x}#{VERSION}"} just simply outputs the generated x and the VERSION variable, on a single string.
It's also possible to do {@print "%s%s", x, VERSION} for the same result.

• I suspect this has to do with the print or php commands, but I'm not sure. Are you fine with plain PHP answers? – user Jul 30 '20 at 16:09
• @user The intended solution has nothing to do with PHP, but sure. As the challenge states, it doesn't have to be the exact solution I was expecting. So, go ahead, you can post your crack. But please specify that it is based in PHP. – Ismael Miguel Jul 30 '20 at 19:35
• Cracked – Dingus Aug 1 '20 at 9:35

## Perl 5.20 (packable with pp from PAR::Packer), Score: 87, Cracked

The ASCII control characters ^F^O^V^X and

!"%'(*+,-/0123456789:;<>@ABCDEFGHIJKLMNOPQRSTUVWXYZ\^abcdefghijklmnopqrstuvwxyz{|~


As a Perl string:

"\x06\x0f\x16\x18" . '!"%\'(*+,-/0123456789:;<>@ABCDEFGHIJKLMNOPQRSTUVWXYZ\\^abcdefghijklmnopqrstuvwxyz{|~'


As hex:

060f161821222527282a2b2c2d2f303132333435363738393a3b3c3e404142434445464748494a4b4c4d4e4f505152535455565758595a5c5e606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7e


This means that the following printable ASCII characters are permitted:

 #$&).=?[]_  No more lists with =>, no more (balanced) parentheses. / is out but ? is back in. My solution works with an ordinary Perl on Linux or Windows, and with any version of suitable vintage. My intent with the PAR::Packer constraint is to express that you shouldn't depend on how Perl is installed. You can run pp foo.pl and run the resulting executable on any machine that can run the resulting binary, even if it doesn't have Perl installed. For information, my solution's size (I didn't attempt to golf): $ wc perl-no-asterisk-braces-comma-parentheses.pl
40  148 3993 perl-no-asterisk-braces-comma-parentheses.pl


Continuation of:

I used several tricks that I got from Dom Hastings's solutions. If you're new to this series, you may want to read our explanations before tackling this one.

• A little worried I'm not going to be able to get this as I'm away next week! I've got all the numbers, all uppercase characters, but still missing a generator for lowercase! I've looked into quite a few mechanisms, still investigating NaN... Hopefully I'll get some time Sunday... – Dom Hastings Jul 31 '20 at 16:00
• @DomHastings After this one, I have another one ready with a slightly different character set that forced me to use a completely different approach to construct letters. And I'm also thinking about one without . — no more concatenation — but I haven't yet found an interesting character set that works. – Gilles 'SO- stop being evil' Jul 31 '20 at 21:52
• Cracked! in probably the most horrendous way possible, but that was fun! – Dom Hastings Aug 2 '20 at 21:19

# Dotty0.20.0-RC1, score: 3 (Cracked)

:\{


Edit: Previously, I had the language marked as Dotty 0.20.0-RC1, but it appears there's an alternate crack(s) that also works on the latest versions of Dotty. This also means that you don't have to download Dotty 0.20, you can just test out your code in Scastie right in your browser.

Note: This The previous solution I had won't work before 0.20 or on the latest version (0.26 currently), so if you want to test it, you'll need SBT or Dotty 0.20 on your computer. However, you probably don't need to do that - just going through the Dotty website (linked above), and perhaps their GitHub repository should be enough. If you do want to test it, I'd suggest Scastie.

My original solution with Dotty 0.20:

 object Main with
@main
def main = print("" + 58.toChar + 92.toChar + 123.toChar)


But it turns just this works too, because functions can be toplevel in Dotty.

 @main
def main = print("" + 58.toChar + 92.toChar + 123.toChar)


Hint: check the release notes for 0.20. There is also another feature, present since I think 0.18, that helps you do this. (To clarify, the first feature helps you avoid { and the second helps you avoid :, although the first can also help you avoid :).

Hint 2: The answer is very short and not at all complex (it took only 86 characters for me (no golfing)). Also, if you compile it on your computer, there will be 6 files: main.class, Foo$package.class, Foo$package$.class, and their corresponding .tasty files (assuming you name your file Foo.scala). • – Ismael Miguel Aug 4 '20 at 0:17 # ><>, score: 1 - Cracked o  How can you output a character without using the o command? # Intended Solution ab*1+:90p ;  Same trick, but much shorter. • cracked lol – lyxal Aug 12 '20 at 6:35 • @Lyxal Of course it's supposed to be easy lol also that one's poorly golfed see my intended solution – null Aug 12 '20 at 6:37 # ><>, score: 20 0123456789abcdef&loi  loi for loss of input # ><>, score: 22 0123456789abcdef&loi'"  No literals now. • I"m just watching as your answers get progressively bigger and Lyxal still manages to crack them each time :) – user Aug 12 '20 at 17:31 • Well, you've won. I give up. It's just too hard for me to crack this answer................................is what I'd be saying if it wasn't cracked lol – lyxal Aug 12 '20 at 21:25 • @user I've struck again with my longest one yet. – lyxal Aug 12 '20 at 21:26 • @Lyxal For a moment there I felt a little sad, thinking this chain was going to stop. Good to see you haven't broken it yet. HighlyRadioactive, keep the challenges coming! I wish both of you luck. – user Aug 12 '20 at 23:19 # ><>, score: 21 123456789abcdef&loi'"  Two ways. • roses are red, my name is not paul. where's round 8? cause this is cracked, lol – lyxal Aug 13 '20 at 3:52 • @Lyxal Herrings are red, my name is not Lyxal. I don't know ><> at all. Also, you are lazy. – null Aug 13 '20 at 4:11 # ><>, score: 24 123456789abcdef&io'"()=  The second approach. Also no newlines. Also be a little bit golfier please. • golfing is overrated. cracked lol – lyxal Aug 13 '20 at 4:38 # Keg, Score: 55, cracked  - + . 8 ! _ ~ ⑨ \ ; - + . 8 ! _ ~ ⑨ \ ;  View it online! Good luck with this one. Most commands used to generate values are gone. Edit: I just realised the output was invalid. It's fixed now. Sorry about that. • Is the Try it online! link intended? :) – the default. Jul 26 '20 at 11:25 • @mypronoun yes, it is. I copied the out in a new tio page to utilise its formatting. Also, it retains all characters SE might botch. – lyxal Jul 26 '20 at 11:26 • – the default. Jul 26 '20 at 13:02 • Is the official implementation linked required, or can the extended variants used in TIO allowed? – Ethan Chapman Aug 14 '20 at 18:37 • Nevermind, I don't need it anymore. – Ethan Chapman Aug 14 '20 at 19:18 # Javascript, score 80, Cracked Last one for javascript. You have to do jsfuck, but I've disallowed 4 of the important characters. I left you some extra, but you'll have to figure out which ones to use and how to use them. <("MrJock,TVQuizPHDBagsFewLynx.mRjOCKtvqUIZ=phd#bAGSfEWlYNX? 12+34-56*78^90%!')>  Yes, this is possible, by the way. The problems you will encounter, in order: • Making numbers (Notice in the number spot, I left out one operation, use that and one other symbol • Making booleans (The answer to this was posted years ago in a chatroom about JSFuck) • Executing functions (If you saw my previous two cop answers, you know how to do this) My solution was exactly the same as the cracked one above. Php7, score: 14 (cracked) funtim(){}_=/\  # Shakespeare Programming Language, score: 4, cracked by Dingus mMbB  You cannot use the sum of or the difference between, so constructing integers is tricky. Dingus' crack is very similar to what I had in mind. The solution relies on the product, square, square root and factorial operators (which are not well known, since they are not or barely mentioned in the official documentation), and on the fact that SPL only uses integers, so that e.g. 5 can be represented as $$\\sqrt{32}\$$ (the square root of a cunning cute peaceful trustworthy healthy squirrel). • Ha! I figured out! Robber coming soon... – null Aug 19 '20 at 4:45 • Cracked – Dingus Aug 19 '20 at 12:06 • @Dingus Well done! That is very close to the solution I had in mind (modulo the choice of epithets, naturally!) – Robin Ryder Aug 19 '20 at 12:33 • Factorial... Nope. I did find the solution with a search script, however. The b is: the square root of the square of twice the square of the square root of twice the square of the square root of a little little little little little cat. Try b online. imagine I optimizing a program for two days only to find out it was cracked. EDIT: – null Aug 20 '20 at 7:21 • Why not a new mMbBlL challenge? That will almost certainly be more interesting... (Mwahahaha) – null Aug 20 '20 at 7:24 # Python 3, Score 104 Cracked by dingledooper Slithering deeper into Python insanity $ python3 ./test6.py |hexdump -C
00000000  09 0a 0b 0c 0d 0e 0f 10  11 12 13 14 15 16 17 18  |................|
00000010  19 1a 1b 1c 1d 1e 1f 20  21 22 23 24 25 26 2a 2b  |....... !"#$%&*+| 00000020 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c |-./0123456789:;<| 00000030 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c |=>?@ABCDEFGHIJKL| 00000040 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c |MNOPQRSTUVWXYZ[\| 00000050 5d 5e 5f 60 61 62 64 67 6a 6b 6d 6f 71 73 75 76 |]^_abdgjkmoqsuv| 00000060 77 78 79 7a 7c 7e 7f 0a |wxyz|~..| 00000068  This time it's not self-verifying. Verification code: import sys import subprocess as s fname = sys.argv[1] ph = s.Popen(f"python3 {fname}",shell=True,stdout=s.PIPE) out = ph.stdout.read() with open(fname,'rb') as fh: fc = fh.read() matches = [x for x in out if x in fc] if len(matches) == 0: print("Success, no output characters in source") else: print(f"Error, maching characters: {matches}")  Verify output: $ python3 ./verify.py ./test6.py
Success, no output characters in source


Original generator:

import re

code = "print(__dat)"

squots = re.compile("'([^']+)'")

dquots = re.compile('"([^"]+)"')

def fstrchar(x):
return f"{'{'}chr({x}){'}'}"

def fy(x):
return fystr(x.group(1))

def fystr(s):
return f"f'{str().join([fstrchar(ord(x)) for x in s])}'"

def replaceliterals(x):
xx = squots.sub(fy,x)
return dquots.sub(fy,xx)

digits= re.compile("\d+")
def subdigits(x):
return digits.sub(lambda m: f"len({repr(tuple([tuple()]*int(m.group(0)))).replace(' ','')})",x)

code = subdigits(replaceliterals(code))

dat = "".join([chr(x) for x in range(9,128) if chr(x) not in code])

ocode = code

code = code.replace('__dat',subdigits(fystr(dat)))

dat = "".join([chr(x) for x in range(9,128) if chr(x) not in code])

code = ocode.replace('__dat',subdigits(fystr(dat)))

open(1,'w').write(code)


Try the result online!

• Note that newline (0a) appears twice in the output... – M Virts Jan 28 at 20:02
• Also, period (2e) is in the output set, which may be overlooked because of the other periods used to represent non-printing characters. – M Virts Jan 28 at 20:13
• Cracked, i think? – dingledooper Jan 29 at 0:43

# Zsh, 87 bytes, safe

i&I0,Grn4T[wfp8Ll:\|t1~cCEN'zu"e7^DWOv+J35!yKBZkXUxSYq%6=2dQP>MsVo]jRHA*b?ah_/g.F-m9



(note the single trailing newline, which is required)

See here for an explanation.

• This is now safe. – Makonede Feb 3 at 22:48

# 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.

• Cracked – nthistle Jul 27 '20 at 22:58

# 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.

• Cracked although I imagine this wasn't your intention... – Dom Hastings Jul 30 '20 at 17:09
• @DomHastings Most definitely not! But isn't that Ruby + Bash? – Dingus Jul 30 '20 at 19:48
• Hmmm, yeah, I guess. Thought I was pushing it a little... – Dom Hastings Jul 30 '20 at 19:59
• 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. – Gilles 'SO- stop being evil' Jul 30 '20 at 22:51
• If you push an updated challenge that forbids backquote, be sure to also arrange to forbid putc which prints character by their numerical value. – Gilles 'SO- stop being evil' Jul 30 '20 at 23:00

# Part 2: PicoLisp, score: 18 cracked

Segmentation fault


or (similar):

Segmentation fault (core dumped)


(output to STDERR)

A bit harder than my previous answer. . .

• 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. – Dingus Jul 30 '20 at 11:30
• @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. – Wezl Jul 30 '20 at 13:13
• Ah yeah right... I completely overlooked the spaces! Segfaults without them too, though. – Dingus Jul 30 '20 at 13:25
• 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 )... – Dingus Jul 30 '20 at 13:36
• 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. – Gilles 'SO- stop being evil' Jul 30 '20 at 22:46

# ><>, score: 17 - Cracked

0123456789abcdefo


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

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

# ><>, score: 19

0123456789abcdeflol


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

# PHP, Score: 1 Cracked

?
`

No command line flags were used.