18
\$\begingroup\$

Edit 2020-11-06: This challenge has been edited with new provisions to encourage participation. The edits have been bolded for emphasis.

Welcome to a cops and robbers version of Find an Illegal String.

An illegal string is "a string of characters that cannot appear in any legal program in your programming language of choice" (from the linked post).

For this challenge, we will define an almost illegal string, which is a string of characters that is very hard, but not impossible, to include in a valid program.

The Cops' Challenge

  • Choose a programming language, and choose an 'almost illegal string' - this is a sequence of characters that is very hard to include in a valid program without causing it to error.
  • Write a program that contains the 'almost illegal string' as a contiguous substring that does not error.
  • Optionally, you may also specify a set of banned characters. These are characters that do not appear in your program, except in the 'almost illegal string'. (Therefore: banned characters can still appear inside the almost illegal string)

That's it! You will reveal the programming language, the almost illegal string, and the set of banned characters, and challenge robbers to write a program that contains the illegal string but does not error.

For the purposes of this challenge, we define 'does not error' as:

  • Your program exits with exit code 0.
  • Your program does not print any output to standard error.
  • Your program may print anything to standard output, if you wish, but it does not have to.
  • If (and only if) your language always prints output to standard error regardless of the program, such as debugging or timing information, you may instead design a program that only outputs this to standard error. If you are making use of this clause, mention it in your cop post.

The Robbers' Challenge

Find an uncracked answer. Write a program in the language specified that contains as a contiguous substring the almost illegal string specified and does not error. Your program may not use any character in the set of banned characters, unless it is part of the almost illegal string. Your program does not need to be exactly what the cop had in mind. Post an answer to the robber's thread and leave a comment on the cops' answer to crack it.

Clarifications

  • If your cop answer requires a specific operating environment or version, you must specify this in your answer.
  • The cop's almost illegal string that they reveal is to be interpreted with respect to the standard encoding for the language's interpreter. For most programs, this will be UTF8.
  • Solutions should not take any input (via standard input, argv, or any other source) and may assume no such input is given.
  • Solutions must terminate in a finite amount of time. This means entering an infinite loop and getting killed by TIO's 60 second timeout is not a valid solution.
  • Cops should make sure if their almost illegal string contains leading or trailing newlines that it is very clear it does so. Robbers should carefully note any leading or trailing newlines in a cop's post.

Formatting hint

The clearest way to include leading or trailing newlines is to use the backtick syntax for your post:

```

foo

```

Renders as:


foo

To remove any ambiguity, explicitly mention the leading/trailing newlines in your post.

Scoring

After 10 days without a crack, a cop can mark their answer as safe and reveal their solution. Once the cop has revealed their solution, it is no longer able to be cracked.

Cops are scored based on the length (in bytes) of their almost illegal string in their safe answer(s), with lower being better.

Robbers are scored by the number of answers they crack, with higher being better.


Example

Python 3, 5 bytes

Illegal string:

"'1/0

Banned characters:

#'

Python 3, cracks example's answer

Program:

""" "'1/0 """

The idea is that we can just comment out the string, since " is not banned.

\$\endgroup\$
  • 3
    \$\begingroup\$ It looks too hard to find a suitable language for this. Can I impose some extra restricted-source on the robber's code, e.g. banning certain chars, or allowing to add code only after the string, etc? \$\endgroup\$ – Bubbler Nov 5 '20 at 7:25
  • \$\begingroup\$ @Bubbler I'm not super happy about the idea of editing in extra rules after the challenge, but so be it. If there are no answers in the next 12 hours, I will allow cops to ban the use of a set of characters. \$\endgroup\$ – Sisyphus Nov 5 '20 at 9:34
  • 1
    \$\begingroup\$ The number of answers to the original "Find an illegal string" challenge that I flagged for deletion as invalid suggests that this challenge can't possibly be too hard. \$\endgroup\$ – pppery Nov 5 '20 at 14:41
  • \$\begingroup\$ You should probably add the code-golf tag to this question because "Cops are scored based on the length (in bytes) of their almost illegal string". \$\endgroup\$ – SunnyMoon Nov 5 '20 at 17:01
  • 3
    \$\begingroup\$ I don’t really like the fact that the number of banned characters has no impact on the score, as it makes it more open to abuse. However, I do see the problems with trying to incorporate it into the scoring system. Therefore, I’d recommend something like using the number of banned characters as a tie breaker for safe answers of the same length, so it has some impact, but not enough to significantly affect the challenge \$\endgroup\$ – caird coinheringaahing Nov 7 '20 at 1:21

12 Answers 12

6
\$\begingroup\$

Python 2, 5 bytes (cracked by tsh)

bin()

Try it online!

Banned: all characters except alphanumeric characters

abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789

So, you're allowed the above characters and nothing else (in addition to bin() itself).

(This idea isn't mine, I remember it from an earlier challenge, but I don't remember who deserves credit for it.)

\$\endgroup\$
  • \$\begingroup\$ cracked \$\endgroup\$ – tsh Nov 6 '20 at 2:18
  • \$\begingroup\$ @tsh Yup, you got it! \$\endgroup\$ – xnor Nov 6 '20 at 2:22
  • \$\begingroup\$ @PkmnQ Yes, but why wouldn’t it? “Banned: all characters except alphanumeric characters” \$\endgroup\$ – caird coinheringaahing Nov 10 '20 at 2:21
  • \$\begingroup\$ @cairdcoinheringaahing Oh, I just saw the code block and thought that those were the disallowed characters. \$\endgroup\$ – PkmnQ Nov 10 '20 at 11:05
4
\$\begingroup\$

Jelly, 4 bytes, cracked by HyperNeutrino



«{

Try it online!

You may not use newlines. Any other character/byte is fair game


My intended solution was any of the banned characters here aside from . Each of these characters cause the parsing of the link to break, meaning everything before them gets ignored:

Try it online!

\$\endgroup\$
  • \$\begingroup\$ @HyperNeutrino Sorry about that, I realised that it could be easily cracked (in a different way to that) and deleted it just as you commented. I've updated my answer so that neither that nor my old crack would work \$\endgroup\$ – caird coinheringaahing Nov 6 '20 at 1:43
  • \$\begingroup\$ Ah, okay no worries. This would still be valid then right? \$\endgroup\$ – HyperNeutrino Nov 6 '20 at 1:44
  • \$\begingroup\$ @HyperNeutrino It would, although I'm not quite sure why. If you post that as a crack, I'll happily give it to you \$\endgroup\$ – caird coinheringaahing Nov 6 '20 at 1:45
  • \$\begingroup\$ newline and are the same character and while it's conventional to use in strings with multiple lines, the Jelly interpreter literally cannot tell the difference because they get mapped to the same codepoint in the SBCS \$\endgroup\$ – HyperNeutrino Nov 6 '20 at 1:46
  • 1
    \$\begingroup\$ @HyperNeutrino Yeah, but « is a string terminator, so should close the leading . { on a string errors, but for some reason, gets rid of that \$\endgroup\$ – caird coinheringaahing Nov 6 '20 at 1:47
3
\$\begingroup\$

Jelly, 4 bytes, cracked by Unrelated String



«{

Try it online!

I'm giving Jelly another go, but with slightly more restrictions. You may not use quƁƘȤ(ƈɦƙɱɲƥʠʂȥ (the unimplemented commands in Jelly), or newlines, as these make it far too trivial to crack (thanks to HyperNeutrino for showing that)


Neither HyperNeutrino's crack in the comments, nor Unrelated String's crack was my intended solution. Putting a Œ (or any of ÐÆØœæ) with nothing after it at the end causes the same behaviour as any of quƁƘȤ(ƈɦƙɱɲƥʠʂȥ, as they always expect to have a character after them. Without any character, they cause a break in the program chain, meaning that everything before them is ignored:

Try it online!

\$\endgroup\$
  • 1
    \$\begingroup\$ I'm really sorry but........ this. Somehow. Works. (help, jelly is confusing again aah) \$\endgroup\$ – HyperNeutrino Nov 6 '20 at 2:45
  • 1
    \$\begingroup\$ @HyperNeutrino Well, at this point Jelly may not be the best language to go for :/ If you post another crack, I‘ll edit it in in the morning \$\endgroup\$ – caird coinheringaahing Nov 6 '20 at 3:12
  • 1
    \$\begingroup\$ Yeah... I find that Jelly's quite forgiving on not erroring when you input random things that one wouldn't expect to work. rip :/ \$\endgroup\$ – HyperNeutrino Nov 6 '20 at 3:13
  • 1
    \$\begingroup\$ Cracked 😔 \$\endgroup\$ – Unrelated String Nov 6 '20 at 12:32
  • 1
    \$\begingroup\$ @UnrelatedString Not my intended solution, but very nice! \$\endgroup\$ – caird coinheringaahing Nov 6 '20 at 12:33
3
\$\begingroup\$

Haskell, 3 bytes


#"

(begins with a newline)

Disallowed charachters: -

\$\endgroup\$
  • \$\begingroup\$ There are no extra compiler flags, and the file doesn't have to be given a special name right? I can see ways to solve it with either of these concessions, but it looks very tough otherwise. \$\endgroup\$ – Wheat Wizard Nov 6 '20 at 22:51
  • \$\begingroup\$ @WheatWizard there is a solution with neither of those, but I'd be intrested in how you'd use those (I made it so it should be fairly difficult even with that). Unless of course you use QuasiQuotes, but what's the fun in that? \$\endgroup\$ – binarycat Nov 6 '20 at 23:04
  • \$\begingroup\$ I was thinking of either QuasiQuotes or cpp neither of which is super fun. Even less fun is to use literate Haskell by naming the file something.lhs in which case noncommented lines need to be escaped with >, so you can just insert >main=print 3 and the rest will be a comment. \$\endgroup\$ – Wheat Wizard Nov 6 '20 at 23:10
  • 1
    \$\begingroup\$ Ok and I cracked it normally. Really nice answer. I didn't even know I could do that! \$\endgroup\$ – Wheat Wizard Nov 6 '20 at 23:15
  • \$\begingroup\$ @WheatWizard To be honest, some of that sounds much more interesting than the actual solution. \$\endgroup\$ – binarycat Nov 6 '20 at 23:19
3
\$\begingroup\$

R, 2 bytes, cracked by Dominic van Essen

'"

Try it online!

Banned characters (newlines are banned):

'"`#\qel
    

This bans the obvious cracks I can think of, but I wouldn't be surprised if you come up with a crack very different to what I intend.

Dominic van Essen cracked a first version of this challenge, and then a second; then Giuseppe cracked a third version. I have added qel and newlines to the list of banned character to sidestep their cracks.


The solution I had in mind was

assign(intToUtf8(c(37,39,34,37)), c); 1 %'"% 2

Try it online!

The assign call creates a new binary operator, %'"%; it is equivalent to "%'"%" <- c. In R, you can create new operators of the form %x% where x is any string: %}%, %$@% and %µ£$% are all valid operator names. Here, the new operator is equal to the concatenation function c and so the output is the vector 1 2.

Dominic's crack doesn't define the operator; he simply buried it in a try call, which is also valid R code.

The trick used here means that any future attempt at an almost illegal string will probably have to ban the % character.

\$\endgroup\$
  • \$\begingroup\$ does this count as a crack? \$\endgroup\$ – Dominic van Essen Nov 11 '20 at 21:46
  • \$\begingroup\$ @DominicvanEssen Nice find! That surely counts, and isn't what I had intended. Since the challenge is very new, I'll edit it to add q to the banned characters (rather than posting a new challenge), but feel free to post your crack to the robbers' thread. \$\endgroup\$ – Robin Ryder Nov 11 '20 at 22:06
  • \$\begingroup\$ what about this then? \$\endgroup\$ – Dominic van Essen Nov 11 '20 at 22:19
  • 2
    \$\begingroup\$ Nah, this is fine by me. We'll just start the safety period from the latest version :-) \$\endgroup\$ – Giuseppe Nov 13 '20 at 17:56
  • 1
    \$\begingroup\$ cracked - and I suspect that this was finally what you had in mind...? \$\endgroup\$ – Dominic van Essen Nov 14 '20 at 0:37
2
\$\begingroup\$

Ruby, 17 bytes, cracked by Dingus

=end
#{"""'}
=end

(no newline at start)

Disallowed charachters: N

\$\endgroup\$
  • 1
    \$\begingroup\$ Cracked \$\endgroup\$ – Dingus Nov 6 '20 at 23:34
2
\$\begingroup\$

Julia, 5 bytes, Cracked by Dingus

?""":

Disallowed charachters: #

\$\endgroup\$
  • \$\begingroup\$ Cracked \$\endgroup\$ – Dingus Nov 7 '20 at 2:35
  • \$\begingroup\$ @Dingus That's a pretty simple solution, don't know how I missed it. I made a more difficult version that should require the intended solution. \$\endgroup\$ – binarycat Nov 8 '20 at 20:19
2
\$\begingroup\$

Julia, 6 bytes

?""":

There is a zero width space before the :

Disallowed characters: #

\$\endgroup\$
  • \$\begingroup\$ Cracked \$\endgroup\$ – Dingus Nov 12 '20 at 0:33
1
\$\begingroup\$

Ruby, 17 bytes

=end
#{"""'}
=end

Disallowed characters: N,%

This time I made it a bit harder.

\$\endgroup\$
  • \$\begingroup\$ Cracked, though not sure it's what you intended. \$\endgroup\$ – Dingus Nov 7 '20 at 0:39
1
\$\begingroup\$

Ruby, 18 bytes

=end
#{/"""'}
=end

Disallowed characters: N,%,/

my final variation, hopefully the next solution is the intended one.

\$\endgroup\$
  • \$\begingroup\$ The approach used in my second crack also works for this version. Is there supposed to be another disallowed character? \$\endgroup\$ – Dingus Nov 7 '20 at 0:54
  • 1
    \$\begingroup\$ @Dingus I guess there is now. I thought the / would stop the regex approach, but I should have checked. \$\endgroup\$ – binarycat Nov 7 '20 at 1:00
  • \$\begingroup\$ And just to clarify, the almost illegal string is the same as before - / is not part of it any more? (Asking because the header still says 18 bytes.) \$\endgroup\$ – Dingus Nov 7 '20 at 1:05
  • \$\begingroup\$ @Dingus It's supposed to be there, not sure what happened to it. I probably don't need it but I'd hate for not including it to be the reason another solution slips past. \$\endgroup\$ – binarycat Nov 7 '20 at 1:08
  • 1
    \$\begingroup\$ @Dingus almost. My version used unintrpolated docstrings, but that works too. If only I put the / on the other side... \$\endgroup\$ – binarycat Nov 7 '20 at 1:22
1
\$\begingroup\$

Zsh

 
#include <cstdlib> 
#include <iostream> 
 
int main() { 
    srand(time(NULL)); 
    hello(); 
    return rand() % 2; 
} 
 
/* 
  main 
  a=0 
  \ 
  print "$((1/$a))" 
*/ 
 
void hello() std::cout << "Hello, World!" << std::endl; 
 
  • Allowed characters: all printable ASCII except blxy<'`$ (lowercase B, L, X, and Y, single-quote, grave, dollar sign)
  • Please note all the leading and trailing whitespace.

Probably not too hard but you may learn a lot about the many - shall we say "quirks" - of zsh.

\$\endgroup\$
  • \$\begingroup\$ Pretty sure this is not what you had in mind? \$\endgroup\$ – xigoi Nov 7 '20 at 17:48
  • \$\begingroup\$ @xigoi no, I forgot to disallow < oops \$\endgroup\$ – pxeger Nov 7 '20 at 18:04
  • \$\begingroup\$ Even simpler exploit, which probably can't be avoided unfortunately. \$\endgroup\$ – xigoi Nov 7 '20 at 19:28
  • \$\begingroup\$ @xigoi Clearly I didn't think carefully enough about this \$\endgroup\$ – pxeger Nov 7 '20 at 19:32
1
\$\begingroup\$

Desmos, 2 bytes, cracked by PkmnQ

Substring:


\

(Note the newline in the beginning)

Banned characters: All alphanumeric characters

abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789

I'm hoping that most people are not familiar with Desmos here, so people wouldn't know what to try.

Note:

An expression in Desmos would be considered an error if it shows a "danger sign" next to the expression, like this:

\$\endgroup\$
  • 1
    \$\begingroup\$ Cracked \$\endgroup\$ – PkmnQ Nov 10 '20 at 0:29
  • \$\begingroup\$ @PkmnQ You got it! \$\endgroup\$ – Aiden Chow Nov 10 '20 at 1:53

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.