52
\$\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 the have written.

Robbers will be select cop 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 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, or Python 3.9 (pre-release) or even point to a specific implementation. Robbers 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 flag 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>

\$\endgroup\$
  • 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 at 15:53
  • 1
    \$\begingroup\$ @SomoKRoceS You can use any characters. \$\endgroup\$ – Wheat Wizard Jul 25 at 21:03
  • 3
    \$\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\$ – the default. Jul 26 at 15:09
  • 3
    \$\begingroup\$ @Discretelizard they have the requirement by default at Loopholes that are forbidden by default \$\endgroup\$ – the default. Jul 26 at 15:43
  • 3
    \$\begingroup\$ 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) \$\endgroup\$ – pppery Jul 27 at 23:14

91 Answers 91

3
\$\begingroup\$

Java, Score: 3 (Cracked)

.\

Round two for this solution, fixing the previous crack. As with the original, the output from my solution was to standard error.

| improve this answer | |
\$\endgroup\$
  • 2
    \$\begingroup\$ While I was doing research for this, I stumbled upon this, which is basically almost identical -- since I'm assuming this isn't intended either, I'm going to some time looking for something better (I'm kinda close on a reflection approach). \$\endgroup\$ – nthistle Jul 27 at 3:10
  • \$\begingroup\$ Cracked. @nthistle, you really helped me! \$\endgroup\$ – user Jul 27 at 19:35
  • 1
    \$\begingroup\$ @user Same trick I used, just in a different format; I just made my main class extend Exception, allowing me to invoke printStackTrace without a dot from its constructor. I guess I could have just reposted again blocking colons (to prevent creating an Autocloseable from a Throwable), but I think twice is enough for one solution, especially when you're that close. Good work! ...still would be interested in seeing the Reflection that nthistle was planning, though... \$\endgroup\$ – MCross Jul 27 at 21:51
  • \$\begingroup\$ Not sure you can use reflection for this - I just spent half the day trying to do it, but you have to use dots in Java to do anything more than this \$\endgroup\$ – user Jul 27 at 21:53
  • 1
    \$\begingroup\$ Yeah, the reflection ended up being a non-starter. The originally idea was basically to use method references (which you only need :: to get) to something like System.err::write and then find a way to invoke them, but invoking method references in Java basically requires ., unless I could find something in the standard library that would invoke it for me (unlikely). Likewise, you can't really use reflection to even access the err attribute of System without using a . somewhere. \$\endgroup\$ – nthistle Jul 27 at 22:50
3
\$\begingroup\$

Perl 5 + -p, Score: 77, Cracked!

 "#'+\-/0123456789:<>ABCDEFGHIJKLMNOPQRSTUVWXYZ\^`abcdefghijklmnopqrstuvwxyz|~

Note: there is a leading space on this line. This leaves you with:

!$%&()*,.;=?@[]_{}

So much for trying to get a low score, there's too many ways to do it!

My approach

First, it's necessary to break out of the while(<STDIN>) loop using }{. My aim wasn't to stop printing, but to make generating the string difficult. Without access to any letters immediately, it's tricky, but using the trick Gilles used $_=*_ you get main::_ which provides a and : (stored in $;) which we'll need later. Accessing these is also tricky as you can't index into strings directly like you can in some languages, but we still have ? which (up until v5.22.0) works similarly to /.../ allowing us to repeatedly match a section, store in $_ (via $_=$&) and match again. a&_ yields A and using that in a range with _ (or aa/AA) produces the list of uppercase and lowercase chars needed (stored in @@ and @!), accessing the indices is a little tricky without numbers, but these can be easily generated using list lengths to generate 0-9 and then concatenation to build larger numbers, although having enough short variables to store data in is an annoying problem to have. To generate the string I used a program to build the numbers I wanted, but it would be a lot shorter using ranges and I pass the codepoints into pack (by calling CORE::pack, via &{'CORE::pack'})using C77 as the definition which stores the desired string in $_ which is implicitly printed.

}{
$_=*_;
?......$?;
$_=$&;
?.?;
@@=$&.._;
@!=(_&$&).._;
?..$?;
$_=$&;
?.?;
$;=$&;
$%=!$?;
$==()=(_,_);
${$![$?]}=()=(_,_,_);
$$=()=(_,_,_,_);
$*=()=(_,_,_,_,_);
$,=()=(_,_,_,_,_,_);
$.=()=(_,_,_,_,_,_,_);
$@=()=(_,_,_,_,_,_,_,_);
$}=()=(_,_,_,_,_,_,_,_,_);
$_=&{$![$=].$![$%.$$].$![$%.$.].$![$$].$;.$;.$@[$%.$*].$@[$?].$@[$=].$@[$%.$?]}(
$![$=].$..$.,
${$![$?]}.$=,
${$![$?]}.$$,
${$![$?]}.$*,
${$![$?]}.$},
$$.${$![$?]},
$$.$*,
$$.$.,
$$.$@,
$$.$},
$*.$?,
$*.$%,
$*.$=,
$*.${$![$?]},
$*.$$,
$*.$*,
$*.$,,
$*.$.,
$*.$@,
$,.$?,
$,.$=,
$,.$*,
$,.$,,
$,.$.,
$,.$@,
$,.$},
$..$?,
$..$%,
$..$=,
$..${$![$?]},
$..$$,
$..$*,
$..$,,
$..$.,
$..$@,
$..$},
$@.$?,
$@.$%,
$@.$=,
$@.${$![$?]},
$@.$$,
$@.$*,
$@.$,,
$@.$.,
$@.$@,
$@.$},
$}.$?,
$}.$=,
$}.$$,
$}.$,,
$}.$.,
$}.$@,
$}.$},
$%.$?.$?,
$%.$?.$%,
$%.$?.$=,
$%.$?.${$![$?]},
$%.$?.$$,
$%.$?.$*,
$%.$?.$,,
$%.$?.$.,
$%.$?.$@,
$%.$?.$},
$%.$%.$?,
$%.$%.$%,
$%.$%.$=,
$%.$%.${$![$?]},
$%.$%.$$,
$%.$%.$*,
$%.$%.$,,
$%.$%.$.,
$%.$%.$@,
$%.$%.$},
$%.$=.$?,
$%.$=.$%,
$%.$=.$=,
$%.$=.$$,
$%.$=.$,
)

Try it online! (with slight modifications to make it work on more moderns versions)

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ Cracked. I found -p to be an extra difficulty. Was that intended, or did you intend a completely different approach for which -p would help? \$\endgroup\$ – Gilles 'SO- stop being evil' Jul 28 at 1:19
  • \$\begingroup\$ @Gilles'SO-stopbeingevil' Nice one! It was intended to give you an easy out, but it's not obvious, it'd possible to prepend the code with }{ and escape out of the block, apologies that it caused extra stress! I think you got all the rest of the tricks and underhanded stuff I laid out, ?...? was worrying me, I didn't know if it was too obscure! I'll share my solution later too when I'm at the computer! \$\endgroup\$ – Dom Hastings Jul 28 at 6:18
  • \$\begingroup\$ Hey, the fun of the search is the point. We certainly haven't reached the end. My turn to cop. Without -p, though I'm curious if a solution for -p exists without {. I made my challenge mostly because I was close to a solution without using *=, then I realized that *_ made things a lot simpler. \$\endgroup\$ – Gilles 'SO- stop being evil' Jul 28 at 12:34
3
\$\begingroup\$

PicoLisp , score: 1, Cracked

(

Writing lisp without parentheses is really easy, with picolisp.

| improve this answer | |
\$\endgroup\$
  • 2
    \$\begingroup\$ Cracked (Btw, this was fun!) \$\endgroup\$ – Ismael Miguel Jul 27 at 18:10
  • \$\begingroup\$ The output of the linked crack is : (, not (. If this was the intended solution, the challenge is wrong. How do you get picolisp not to display a prompt? \$\endgroup\$ – Gilles 'SO- stop being evil' Jul 30 at 22:49
  • \$\begingroup\$ Comments about a cracked answer shouldn't be on thr cops' post. As you double-commented, I explained my answer there. \$\endgroup\$ – Ismael Miguel Jul 31 at 13:21
  • \$\begingroup\$ @Gilles'SO-stopbeingevil' You run the program as a script like pil script.l instead of typing it in after running pil like jdoodle seems to like to do. \$\endgroup\$ – Wezl Jul 31 at 13:45
3
\$\begingroup\$

APL (Dyalog Unicode), Score: 5, cracked

uvUV┼

Can you generate the Unicode box-drawing character U+253C or ⎕UCS 9532 without ⎕UCS or ⎕AV?

Any system variable setting (⎕IO, ⎕ML, etc.) can be used. The code should work in TIO's code section, so SALT (and user command) is not available. Since there is no trailing newline in the expected output, use -printing (which prints to STDERR).

| improve this answer | |
\$\endgroup\$
3
\$\begingroup\$

Ruby, Score: 11, Cracked

p.`'"?%([:<

Take 2, after @DomHastings and @Gilles'SO-stopbeingevil' found unintended weaknesses in the original. I've fortified this version by adding p and ` to the list of forbidden characters. As before, my code outputs to STDOUT with no trailing newline and works for Ruby 1.8.7 onwards.

| improve this answer | |
\$\endgroup\$
3
\$\begingroup\$

Dirty, Score: 8 - Cracked

hd of []

This is way too easy for people who knows this language... (I don't.)

Intended Solution:

1

Yeah, you read that right.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Cracked \$\endgroup\$ – Dingus Aug 1 at 2:51
3
\$\begingroup\$

Dupdog, Score: 10 - Cracked

[\x0e][\x0c]
[\x10][\x0e][\x18][\x16]
39

May I join the fun?

Inside brackets are escape characters. Assuming linux line-breaks.

Intended Solution

~!!?*

I love short codes.

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ This should be really really trivial, by the way - none of the three Dupdog commands (?!~) happens to be in the output, so basically, this is a "Print X" challenge. The answer is suspiciously short - can you find it? \$\endgroup\$ – null Jul 28 at 13:22
  • \$\begingroup\$ Cracked \$\endgroup\$ – Dingus Aug 1 at 4:20
3
\$\begingroup\$

Malbolge, score: 2, Cracked

To

In Malbolge, the "print X" part of the challenge should be hard enough by itself.


Original solution:

('&%$#"!~}|{2V0w.R?

Try it online!

| improve this answer | |
\$\endgroup\$
3
\$\begingroup\$

Fortran (GFortran), Score: 18, Cracked

Pp1234567890'"+-*/

My code outputs to STDOUT with no leading whitespace and a trailing newline.


My solution

@Gilles'SO-stopbeingevil' used exactly the same approach in the crack, with minor differences in implementation:

 character(bit_size(i)) :: fmt, out
 izero = floor(epsilon(r))  ! len_trim(achar(bit_size(i))) also works
 ione = ceiling(epsilon(r)) ! len(achar(bit_size(i))) also works
 itwo = ibset(izero,ione)
 ithree = ibset(ione,ione)
 ifour = ibset(izero,itwo)
 ifive = ibset(ifour,izero)
 isix = ibset(ifour,ione)
 iseven = ibset(isix,izero)
 ieight = ibset(izero,ithree)
 inine = ibset(ieight,izero)
 iten = ibset(ieight,ione)
 ieleven = ibset(iten,izero)
 itwelve = ibset(ieight,itwo)
 ithirteen = ibset(itwelve,izero)
 ifourteen = ibset(itwelve,ione)
 ififteen = ibset(ifourteen,izero)
 isixteen = ibset(izero,ifour)
 iseventeen = ibset(isixteen,izero)
 ieighteen = ibset(isixteen,ione)
 fmt(ione:ione) = achar(ibset(ieight,ifive))
 fmt(itwo:itwo) = achar(ibset(ione,isix))
 fmt(ithree:ithree) = achar(ibset(inine,ifive))
 out(ione:ione) = achar(ibset(isixteen,isix))
 out(itwo:itwo) = achar(ibset(ibset(isixteen,ifive),isix))
 out(ithree:ithree) = achar(ibset(iseventeen,ifive))
 out(ifour:ifour) = achar(ibset(ieighteen,ifive))
 out(ifive:ifive) = achar(ibset(ibset(ithree,ifour),ifive))
 out(isix:isix) = achar(ibset(ibset(ifour,ifour),ifive))
 out(iseven:iseven) = achar(ibset(ibset(ifive,ifour),ifive))
 out(ieight:ieight) = achar(ibset(ibset(isix,ifour),ifive))
 out(inine:inine) = achar(ibset(ibset(iseven,ifour),ifive))
 out(iten:iten) = achar(ibset(ibset(ieight,ifour),ifive))
 out(ieleven:ieleven) = achar(ibset(ibset(inine,ifour),ifive))
 out(itwelve:itwelve) = achar(ibset(isixteen,ifive))
 out(ithirteen:ithirteen) = achar(ibset(iseven,ifive))
 out(ifourteen:ifourteen) = achar(ibset(itwo,ifive))
 out(ififteen:ififteen) = achar(ibset(ieleven,ifive))
 out(isixteen:isixteen) = achar(ibset(ithirteen,ifive))
 out(iseventeen:iseventeen) = achar(ibset(iten,ifive))
 out(ieighteen:ieighteen) = achar(ibset(ififteen,ifive))
 write(isix,fmt(ione:ithree)) out(ione:ieighteen)
 end
 

Try it online!

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Cracked. By the way, I don't know Ruby or Fortran beyond the hello world stage. It's an interesting journey. \$\endgroup\$ – Gilles 'SO- stop being evil' Aug 1 at 16:11
  • \$\begingroup\$ I had a feeling this was coming. Maybe now you should say didn't know. 'Hello, World!' generally doesn't take 1000+ bytes in either language :) \$\endgroup\$ – Dingus Aug 2 at 4:09
3
\$\begingroup\$

Arn, Score: 23 Cracked

15125177041707640200000

Ignore the fact that Arn has a compressed form, the ASCII-only version does not contain any of these characters

My Solution:

(:*:*:*:*++++++++++++++++++++++++++++++++++++);o

You use the ++ prefix to increment to 18, square it 4 times, and then conver to octal.

| improve this answer | |
\$\endgroup\$
  • 2
    \$\begingroup\$ I do not know this language, but can we do something like 9/9+9/9+9/9+9/9+...? \$\endgroup\$ – the default. Aug 27 at 4:00
  • 1
    \$\begingroup\$ Can Arn please have an online interpreter? (Or one that can be run in TIO.) \$\endgroup\$ – null Aug 27 at 5:17
  • \$\begingroup\$ It does have an online compiler, here. \$\endgroup\$ – ZippyMagician Aug 27 at 11:15
  • \$\begingroup\$ Yes, @my pronoun is monicareinstate, I believe you could get that answer to work, but that is not the method I intended (so I hope you could figure out a different method). \$\endgroup\$ – ZippyMagician Aug 28 at 2:29
  • \$\begingroup\$ Cracked \$\endgroup\$ – Dingus Aug 28 at 3:03
3
\$\begingroup\$

Java, Score: 3 Cracked

\[;

This eliminates unicode literals, arrays, and semicolons

| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

Keg, Score: 10 Cracked

doesn't\\`

This'll take some extra thinking for you all. Apparently not.

¶7ƛ;¶¶Z¶ⁿ2+¶`¶

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Cracked \$\endgroup\$ – user92069 Jul 26 at 5:31
  • \$\begingroup\$ @Third-party'Chef' beat me to it by less than a minute :) \$\endgroup\$ – Ethan Chapman Jul 26 at 5:32
2
\$\begingroup\$

R, Score=13

-/+0123456789

Printing characters without using digits should be tricky (and I'm pretty confident that you won't find a way to sneak in a utf8ToInt!). I wouldn't be surprised if the crack ends up completely different from my own solution.

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ Robin: I hope that I have not duplicated your challenge, and that adding some extra characters to my challenge actually makes it tricker. If your secret solution will already crack my challenge, I'll withdraw it (but obviously I've already cracked yours...). \$\endgroup\$ – Dominic van Essen Jul 26 at 13:16
  • \$\begingroup\$ @DominicvanEssen No, my solution doesn't crack yours, so it isn't a duplicate! And I thought mine was hard... \$\endgroup\$ – Robin Ryder Jul 26 at 13:20
  • 4
    \$\begingroup\$ I'm trying to make a new crack to yours that doesn't give away my own one. That could even be a new challenge: 'crack X without cracking Y'... \$\endgroup\$ – Dominic van Essen Jul 26 at 13:29
  • 1
    \$\begingroup\$ Cracked! curious what your intended solution was. I don't think this approach will be quite so fruitful for Dominic's, though. \$\endgroup\$ – Giuseppe Jul 26 at 15:38
  • 1
    \$\begingroup\$ @Giuseppe Well done! I'll wait a couple of days before adding my (completely different) solution, as I might be able to channel the idea into another challenge. \$\endgroup\$ – Robin Ryder Jul 26 at 19:32
2
\$\begingroup\$

Befunge 93, score 12 (Cracked)

,0123456789"

Not too hard to figure out in theory, but a pain to implement (at least the way I did it).

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Cracked \$\endgroup\$ – pppery Jul 26 at 17:23
2
\$\begingroup\$

Python 2, Score: 14 (Cracked)

"'0123456789dt

Note: There is no newline at the end

| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

05AB1E, Score: 21, Cracked

X = •”“’‘Ž…„'"ഭ0123456789

A bit more difficult entry :)

edit

Cracked by @nthistle

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Cracked \$\endgroup\$ – nthistle Jul 25 at 23:51
  • 1
    \$\begingroup\$ I'm thinking without blacklisting ç or some way to get arbitrary values on the stack, it's going to be difficult to stop my approach from working (and removing the ability to put arbitrary values on the stack will make it hard to do anything in 05AB1E...) \$\endgroup\$ – nthistle Jul 25 at 23:52
  • \$\begingroup\$ True. I'll think about that. \$\endgroup\$ – SomoKRoceS Jul 26 at 18:45
2
\$\begingroup\$

Ruby, Score: 7, Cracked by @Dom Hastings

p<.$a1d

Attempt number 3 after being foiled by @nthistle and @Dom Hastings.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ So I've got another crack, but I'm pretty sure it's still not the one you're expecting and I don't want you to get bored of having alternative cracks, so I'm looking for more alternatives... \$\endgroup\$ – Dom Hastings Jul 26 at 18:51
  • \$\begingroup\$ I found another method, which could be a little closer perhaps? codegolf.stackexchange.com/a/207640/9365 \$\endgroup\$ – Dom Hastings Jul 26 at 19:25
  • \$\begingroup\$ That was it! Nicely researched. \$\endgroup\$ – histocrat Jul 26 at 21:02
2
\$\begingroup\$

J, Score: 3 (Cracked)

Aiming for a low score, so might not be hard to crack. Blocks the straight-forward ways to convert a number to a character.

au.

Only tested with j9.

| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

R (with CRAN packages installed), Score: 3, cracked

([{

Yes folks, no brackets!

You may assume that any CRAN package is installed, but as per standard rules not loaded.

I haven't posted an R version number although your solution might reasonably depend on that, I'm happy to accept an answer for any version of R after 3.0.0.

Update: this is possible without using any CRAN packages, but given I originally posted this allowing CRAN packages, I won't change it.

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ Cracked (no packages needed) \$\endgroup\$ – Robin Ryder Jul 27 at 12:23
2
\$\begingroup\$

J, Score: 3 (Cracked)

After nthisle cracked my previous challenge, here is a slightly harder challenge.

u:.
| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

R, Score=27, cracked by Dominic van Essen

We have had several R challenges on this thread already. All the solutions needed a t (for cat, get or other functions), so here is one where you will have to avoid that letter. I also threw in a v to forbid eval, as I don't really understand all of the magic you can do with eval...

t <-
"0123456789=[\\]^_`v"

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ I like that the output is perfectly fine R code, but now I'm definitely not going to get any work done today. \$\endgroup\$ – Giuseppe Jul 27 at 16:54
  • \$\begingroup\$ I've got a solution, but I won't have time to create all the numbers by making sum(T+T+...) for a while yet... \$\endgroup\$ – Dominic van Essen Jul 27 at 18:24
  • \$\begingroup\$ @DominicvanEssen Note that you are allowed *, which can make it easier to represent numbers. \$\endgroup\$ – Robin Ryder Jul 27 at 18:48
  • \$\begingroup\$ That's a good point. I've posted an explanation of the crack now. I'll update it in a little bit by substituting in all the numbers... Hope it's Ok for now. \$\endgroup\$ – Dominic van Essen Jul 27 at 18:55
  • \$\begingroup\$ Good enough for me, well done! I should have disallowed more characters. My solution would allow for disallowing l and o as well; I'll probably post it tomorrow (but I don't want to flood this thread with rather similar R challenges!) \$\endgroup\$ – Robin Ryder Jul 27 at 19:23
2
\$\begingroup\$

TSQL (SQL server), Score: 1, Cracked

X = (

I have made a post on meta which asks what is considered SQL output, but no answer yet. Feel free to consider my post cracked on either the result-set output (1x1 or 0x1 cells only though), or the print output (print/raiserror low severity). I am not including raiserror with high severity because OP said in case we use the error output we should say so, and I don't.

My first post here, feel free to edit if I missed anything.

| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

Ruby, Score: 23, Cracked

cdp0123456789.`'"?%([:<

Take 3, and hopefully this time I've better captured my intentions! The score has more than doubled over the previous iteration, largely thanks to the digits. Also now banned are c and d. For what it's worth, my code has hardly changed.

Previous challenges in the series:

Take 1 (score 9), cracked by @DomHastings. (@Gilles'SO-stopbeingevil' exposed another fatal flaw.)

Take 2 (score 11), cracked by @Gilles'SO-stopbeingevil'.

| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

Ruby, Score: 16, Cracked

cdopr.`'"?%([{:<

OK, fourth and final take! The score has actually dropped now that I've realised (thanks to chief nemesis @Gilles'SO-stopbeingevil') that banning digits is redundant. But there will be no more String or Array (r), no more Float (o), and no more interpolation into regexps ({), thank you very much.

I'll surrender if this one is cracked . . . probably more like when this one is cracked :)

Previous challenges in the series:

Take 1 (score 9), cracked by @DomHastings. (@Gilles'SO-stopbeingevil' exposed another fatal flaw.)

Take 2 (score 11), cracked by @Gilles'SO-stopbeingevil'.

Take 3 (score 23), cracked by @Gilles'SO-stopbeingevil'.


My solution

I surrender. Here is my code:


 X = RUBY_COPYRIGHT
 D = RUBY_DESCRIPTION
 M = X=~/M/ && $&
 Y = X=~/Y/ && $&
 a = X=~/a/ && $&
 b = X=~/b/ && $&
 e = D=~/e/ && $&
 g = X=~/g/ && $&
 i = X=~/i/ && $&
 k = X=~/k/ && $&
 n = D=~/n/ && $&
 O = X=~/O/i && $&
 P = X=~/P/i && $&
 R = X=~/R/i && $&
 s = X=~/s/ && $&
 t = X=~/t/ && $&
 u = X=~/u/ && $&
 One = X=~/\w\w\w\w-/ && $&=~/^\w/ && $&
 thRee = X=~/\w-/ && $&=~/^\w/ && $&
 nine = X=~/\w\w\w-/ && $&=~/^\w/ && $&
 sPaCe = X=~/ / && $&
 DOt = D=~/\w\s\w\D/ && $&=~/\D$/ && $&
 lPaRen = X=~/\WC\W/ && $&=~/^\W/ && $&
 RPaRen = X=~/)/ && $&
 lsqbR = D=~/\S+$/ && $&=~/^\W/ &&$&
 RsqbR = D=~/]/ && $&
 take = DOt+t+a+k+e
 C = eval lPaRen+b+DOt+DOt+e+RPaRen+take+lPaRen+nine+RPaRen+lsqbR+One+RsqbR # eval "('b'..'e').take(9)[1]"
 S = eval lPaRen+lPaRen+M+DOt+DOt+Y+RPaRen+take+lPaRen+nine+RPaRen+lsqbR+thRee+RsqbR+DOt+DOt+Y+RPaRen+take+lPaRen+nine+RPaRen+lsqbR+thRee+RsqbR # eval "(('M'..'Y').take(9)[3]..'Y').take(9)[3]"
 PutC = P+u+t+C+sPaCe
 stRing = S+t+R+i+n+g+sPaCe
 suCC = DOt+s+u+C+C
 zeRO = eval stRing+One+lsqbR+One+RsqbR
 twO = eval stRing+One+suCC
 fOuR = eval stRing+thRee+suCC
 five = eval stRing+fOuR+suCC
 six = eval stRing+five+suCC
 seven = eval stRing+six+suCC
 eight = eval stRing+seven+suCC
 eval PutC+nine+nine
 eval PutC+One+zeRO+zeRO
 eval PutC+One+One+One
 eval PutC+One+One+twO
 eval PutC+One+One+fOuR
 eval PutC+fOuR+six
 eval PutC+nine+six
 eval PutC+thRee+nine
 eval PutC+thRee+fOuR
 eval PutC+six+thRee
 eval PutC+thRee+seven
 eval PutC+fOuR+zeRO
 eval PutC+nine+One
 eval PutC+One+twO+thRee
 eval PutC+five+eight
 eval PutC+six+zeRO

Try it online!

Explanation:

The basic idea is to build the output exclusively by extracting characters from predefined strings, then using those characters to build other necessary characters using eval.

I made the mistake of extracting characters from RUBY_COPYRIGHT and RUBY_DESCRIPTION, neither of which contain the essential c. If I'd used $LOADED_FEATURES, as @Gilles'SO-stopbeingevil' did, I would have had an easier time. I also made things difficult for myself by avoiding digits. Even had digits been banned (as they were in Take 3), they can be easily derived using $$.

RUBY_COPYRIGHT and RUBY_DESCRIPTION are strings (both added in 1.8.7) that both contain some fixed text and some version/platform-dependent text. For the Ruby version currently on TIO, these strings are as follows, with fixed text (common across all Ruby versions/platforms) indicated in bold:

RUBY_COPYRIGHT = ruby - Copyright (C) 1993-2019 Yukihiro Matsumoto
RUBY_DESCRIPTION = ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]"

I limited myself to extracting characters from the fixed parts of these strings so as not to tie the code to a particular version/platform.

I start out by grabbing a bunch of necessary letters through simple regexp matching, with the i flag used for case insensitivity to help with o, p, and r. I also grab the version-independent digits 1, 3, and 9, the space, . (for method calls), ( and ) (for grouping), and [, and ] (for indexing).

Now comes the tough part: I need a c to create either chr or putc (I used the latter) to convert numbers to their corresponding ASCII characters. I also need a way to create the remaining digits that I don't have, and sure enough the method to do that—succ—also contains c. (A synonym for succ is next, which I avoided because I couldn't get an x without using the platform-dependent x86_64-linux part of RUBY_DESCRIPTION.) Agonisingly, there are two (uppercase) Cs in RUBY_COPYRIGHT, but with no way to convert them to lowercase (you guessed it, downcase and swapcase also contain c) they're useless.

On top of that, I need an (uppercase) S to make String because succ (called via eval) ends up generating integers rather than strings.

After much wailing and gnashing of teeth, I realised that I had just enough characters to create take, fortuitously allowing me to extract c from the range ('b'..'e'). A double take was needed to get S from the range ('M'..'Y') (Matz's initials). See the comments in the code for a better idea of how this works.

With that out of the way, the rest is pretty straightforward. I make the putc, String, and succ methods by concatenating characters, use these to get the remaining digits, and then print the required characters.

| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

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.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ I suspect this has to do with the print or php commands, but I'm not sure. Are you fine with plain PHP answers? \$\endgroup\$ – user Jul 30 at 16:09
  • \$\begingroup\$ @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. \$\endgroup\$ – Ismael Miguel Jul 30 at 19:35
  • 1
    \$\begingroup\$ Cracked \$\endgroup\$ – Dingus Aug 1 at 9:35
2
\$\begingroup\$

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:

  1. challenge, crack
  2. challenge, crack
  3. challenge, crack
  4. challenge, crack

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.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ 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... \$\endgroup\$ – Dom Hastings Jul 31 at 16:00
  • \$\begingroup\$ @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. \$\endgroup\$ – Gilles 'SO- stop being evil' Jul 31 at 21:52
  • \$\begingroup\$ Cracked! in probably the most horrendous way possible, but that was fun! \$\endgroup\$ – Dom Hastings Aug 2 at 21:19
2
\$\begingroup\$

Dotty 0.26-RC1, Score: 7 (Safe)

"+. p\{

Earlier versions may work too, like 0.25 and 0.24, but I'm not totally sure how low you can go, since Dotty's features keep changing.

Harder version, score: 8 (I still had the same solution for this, but the one above may have alternate cracks, and this doesn't allow them, hopefully.)

"+. p\{[

Update

Since my answer's over a week old now, here's the solution I got (I'm sure it could be made shorter, but whatever)

object`Main`:
    @main
    def`main`=(Console`out`)write(new`String`()concat((34`toChar`)toString)concat((43`toChar`)toString)concat((46`toChar`)toString)concat((32`toChar`)toString)concat((112`toChar`)toString)concat((92`toChar`)toString)concat((123`toChar`)toString)getBytes)

I basically just used concat instead of +, xx.toChar.toString to get around the ", postfix and infix syntax to get around the ., and the backtick to get around the restriction on spaces.

A couple Dotty-specific features that helped: @main meant I didn't have to write (args: Array[String]), saving me [, and Dotty's new indentation-based syntax let's you use : instead of curly braces. Note that even though you see spaces here and in the playground, Dotty does let you use tabs.

Try it in Scastie

Bonus (the same thing, but no parentheses this time)

"+. p\{(

Here's my solution to it (unfortunately, the backticks were removed, because I don't know how to put code in spoilers, but imagine they were there)

 objectMain:
     @main
     defmain=
         vala=34toChar
         valb=43toChar
         valc=46toChar
         vald=32toChar
         vale=112toChar
         valf=92toChar
         valg=123toChar
         valh=40toChar
         vali=newStringBuilder
         iappendaappendbappendcappenddappendeappendfappendgappendh
         valj=itoString
         valk=jgetBytes
         vall=Consoleout

         lwritek
 

Scastie

| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

Dotty 0.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).

| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

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

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ cracked lol \$\endgroup\$ – Lyxal Aug 12 at 6:35
  • \$\begingroup\$ @Lyxal Of course it's supposed to be easy lol also that one's poorly golfed see my intended solution \$\endgroup\$ – null Aug 12 at 6:37
2
\$\begingroup\$

><>, score: 20

0123456789abcdef&lol

Forgot the register... happy now?

| improve this answer | |
\$\endgroup\$

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.