g | x | w | all
Bytes Lang Time Link
004Rust250507T125706ZDeadbeef
nan250509T085022Zjlab
010Python 3210310T185619ZMakonede
nan210218T183532ZMakonede
007Python 3211109T235220ZLarry Ba
015Vyxal210717T093053Zemanresu
004Vim210706T164647ZAaroneou
003Vim210706T164519ZAaroneou
032Pyth210312T151459ZCitty
007Javascript210311T151616ZEtheryte
003Python 3210222T150647Zqwatry
006Python 3210217T230030ZMakonede
005Rust210207T135713ZDeadbeef
004nasm210206T225008ZEasyasPi
013Python 3210204T214814Zqwatry
105JavaScript THREE.js 105 Must include canvas element ~48 bytes210203T181313ZHitchHac
009Desmos210203T170457ZHitchHac
002R201111T203528ZRobin Ry
006Julia201108T201532Zbinaryca
005Julia201106T225813Zbinaryca
002Desmos201109T220443ZAiden Ch
nan201107T080104Zpxeger
018Ruby201107T004713Zbinaryca
017Ruby201106T235919Zbinaryca
017Ruby201106T231336Zbinaryca
003Haskell201106T224233Zbinaryca
004Jelly201106T014037Zcaird co
004Jelly201106T020127Zcaird co
005Python 2201106T012611Zxnor

Rust, 4 bytes, cracked by Themoonisacheese

"'"'

Expecting this to be an easy crack, probably. No compiler flags allowed.

Disallowed characters:

"'/

Themoonisacheese's crack using a shebang, revised disallowed characters:

#"'/

Plain TeX

\def\bye

The document must compile without error (you can't simply comment the whole line: Fatal error occurred, no output PDF file produced!).

Banned character

\

Intended solution

^^\def\bye using that the sequence ^^ will read the next char as an ASCII number.

Python 3, 10 bytes, cracked by The Fifth Marshal


?"""?'''?

Banned characters

Alphanumeric, whitespace, and non-ASCII.


The intended solution makes use of an interesting quirk in the Python parser.

Here's a hint if you want one:

The hint is that there is no hint. (This isn't a joke. This is actually the hint.)


Intended Answer

Hexdump:

00000000: 2300 0a3f 2222 223f 2727 273f  #..?"""?'''?

For some reason,

the Python parser seems to ignore characters following null characters.

So,

it ignores the newline after the #␀, therefore treating the ?"""?'''? as part of the comment.

Fun fact: This was actually posted on the original Find an Illegal String challenge, but when I found a way to get around it, I decided to post it here.

Python 3, 7 bytes, cracked by @EasyasPi

Still not the intended answer, so I'm just revealing it. Scroll to the bottom to see it.


raise

Banned characters

TAB "'(),.=[\]_{|}

Non-ASCII characters are all banned as well. Try it online or validate it online!

Some cracks that work without the banned chars

'''
raise'''
"""
raise"""

raise SystemExit

raiseTABSystemExit # originally posted by EasyasPi here, he found yet another loophole

raise\
SystemExit

raiser=3 # originally posted by EasyasPi on v1 of this challenge

Intended Answer

#coding:U7
quit+ACgAKQ-
raise

This works because

the magic comment at the top sets the file encoding to UTF-7

and

in UTF-7, characters can be encoded by first converting them to their UTF-16 binary representations, and concatenating them if there are multiple characters to be encoded. Here, we want to call quit, so we need to convert (). This becomes 0000 0000 0010 1000 0000 0000 0010 1001. Next, we regroup them into groups of 6, to get 000000 000010 100000 000000 001010 01, and pad the last group with trailing zeros (if necessary). In this case, we get 000000 000010 100000 000000 001010 010000. Finally, we convert these to the corresponding Base64 characters (table here), getting ACgAKQ, prepend a +, and append a -.

So,

() in UTF-7 is +ACgAKQ-. We use this fact to bypass the banned () and call quit anyways, by replacing () with +ACgAKQ-. This exits the program before it can throw any errors.

Python 3, 7 bytes

"""'''$

(Note no starting or trailing newline.)

Disallowed characters:

#

Vyxal, 15 bytes, Cracked by lyxal


«Wi«»Wi»`Wi`Wi

Try it Online!

No bans, do what you want. Note that silently erroring at compile-time (Nothing appears in the 'output' box) counts as an error - even the empty program outputs 0...

My intended solution was prepending a [ to just make sure the code isn't run.

Vim, 4 bytes, cracked by tail spark rabbit ear

<Esc><Esc>ZQ

This one is a bit more difficult than my other Vim one.

Intended Solution:

i<C-o>:<C-r><Esc><Esc>ZQ

Vim, 3 bytes, cracked by tail spark rabbit ear

<Esc>ZQ

A Vim program doesn't really "error out" per se, but ZQ will exit the current file without saving, so it can't be executed in a valid program, thereby making it "illegal".

This is a bit of an easier one, if you know Vim.

Intended Solution:

i<C-v><Esc>ZQ

Pyth, 32 bytes

X$globals()$"imp_print"$mod$

""

Banned characters are:

$\LMN."

Try it online!

Javascript, 7 bytes, cracked by Makonede

...void

Javascript, 8 bytes, cracked by Makonede

Note one trailing space

...void 

Banned characters:

Clarifications: My cop answer works in a browser environment, but there are probably solutions in Node too.

Python 3, 3 bytes, Cracked by user

I can't believe I missed that obvious loophole! I am adding a slightly revised version of my code that should avoid this.

New Answer, 4 bytes, Cracked by Unrelated String

 1=2

Note: There is a space at the beginning of the code.

Banned characters: All non-ascii characters, quotes, and #.

"'#

Try it online!

Old Answer, 3 bytes, Cracked by user:

1=2

Banned characters: All non-ascii characters, quotes, and #.

"'#

Try it online!

My intended solution for both posts:

foo : 1=2

Python 3, 6 bytes, cracked by EasyasPi

@EasyasPi's crack does work (and I'm dumb for letting it work), but I'm not revealing the original solution yet; I've posted a v2 hopefully preventing any loopholes.


raise

Banned characters

 "'(),.:[\]_{|}

Non-ASCII characters are all banned as well. Try it online or validate it online!

Some cracks that work without the banned chars

'''
raise'''
"""
raise"""

raise SystemExit

raise\
SystemExit

Rust, 5 Bytes (Safe)

:! =1

Banned Characters:

|!/"'

A nightly compiler is used, you may pass any flags to rustc if you like.


A crack by @EasyasPi does work (and is brilliant), but I think because the question says "you must write a program that contains ...", if your code is not designed to run, it isn't a program :)

The intended solution

The idea is to create a local variable that has the never type, call some functions on the integer 1 such that it becomes the never type.

However, with ! as a banned character, we can't simply put the #![feature(never_type)] attribute on the top of the program. We must use an unstable rustc flag that allows us to inject crate-level attributes. The command to compile would be:

cargo rustc -- -Z crate-attr='feature(never_type, core_panic)'

Because closures (|| something) and the use of the ! type outside are restricted, we must operate on the integer literal with provided functions. This is where the core_panic feature comes in and gives us a nice way to transform a &str into !. We know the start and the end, we can just put them together:

use std::io::stdout;
use core::panicking::panic_str;
use std::borrow::Borrow;

fn main() {
    let a:! =1i8.checked_neg().as_ref().map(ToString::to_string).as_ref().map(Borrow::borrow).map(panic_str).unwrap();
}

nasm, 4 bytes, safe

[al]

Banned characters:

;"`'%#

Solution:

section is, as far as I know, the only thing in NASM which accepts an arbitrary string without quotes.

        section [al]
        section .text
        global _start
_start:
        mov     eax, 60
        syscall
Try it online!

Stop giving me these assembly ones for free. 😔

Python 3, 13 bytes, Cracked by EasyasPi

int(А,В,С)

Banned Characters: All ascii characters except 2()~+ and newlines. '"#= are banned.

 !"#$%&'*,-./013456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}

The solution makes use of an odd python 3 feature.

Try it online!

JavaScript (THREE.js 105) (Must include canvas element) ~48 bytes


const scene = new THREE.Scene();
scene.add(cube);

Note empty lines Try it!

Banned Characters: All quote characters

/

Desmos, 9 bytes,

sort(3,2

Banned characters: New Lines


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:

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.

Julia, 6 bytes

?""":

There is a zero width space before the :

Disallowed characters: #

Julia, 5 bytes, Cracked by Dingus

?""":

Disallowed charachters: #

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:

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; 
 

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

Ruby, 18 bytes

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

Disallowed characters: N,%,/

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

Ruby, 17 bytes

=end
#{"""'}
=end

Disallowed characters: N,%

This time I made it a bit harder.

Ruby, 17 bytes, cracked by Dingus

=end
#{"""'}
=end

(no newline at start)

Disallowed charachters: N

Haskell, 3 bytes


#"

(begins with a newline)

Disallowed charachters: -

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!

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!

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