In this question I will talk about programs as strings, this is strings of bytes, not characters. How your resultant program is rendered or displayed is not important to this challenge, only how it appears in memory matters.

A pristine program is a program \$S\$ that when run does not error, however it will error whenever a continuous substring of size \$n\$, where \$1\leq n < \left|S\right|\$, is removed.

A filthy program is the opposite, it is a program \$S\$ that when run does error, however whenever a continuous substring of size \$n\$, where \$1\leq n < \left|S\right|\$, is removed, it does not error.

For this challenge an error is non-empty output to STDERR.

Your challenge is to write a filthy program that uses as many unique bytes as possible. This means you will get one point for every unique byte that appears in your code with a larger score being better. The maximum score is thus 256.

  • \$\begingroup\$ Is it even possible to answer this in languages that involve brackets/parentheses? It would be possible to remove some substring from code so that there would be mismatched brackets. \$\endgroup\$ Commented Jul 3, 2018 at 14:49
  • \$\begingroup\$ @JungHwanMin If the language enforces balanced parentheses I would suspect that it would be impossible. \$\endgroup\$
    – Wheat Wizard
    Commented Jul 3, 2018 at 14:53
  • \$\begingroup\$ @CatWizard so a filthy program does not error when a continuous substring of characters (i.e. not continuous set of bytes) is removed, correct? \$\endgroup\$ Commented Jul 3, 2018 at 15:11
  • \$\begingroup\$ @JungHwanMin Sorry. It may or may not. We only care about continuous strings. \$\endgroup\$
    – Wheat Wizard
    Commented Jul 3, 2018 at 15:14
  • 5
    \$\begingroup\$ This script generates all the programs necessary to check \$\endgroup\$ Commented Jul 3, 2018 at 22:49

8 Answers 8


Unary, 14 bytes


This encodes the brainfuck program [, which errors due to unmatched brackets.

Removing bytes will result in >, <, +, -, ., , or the empty program, which are valid brainfuck programs.

  • \$\begingroup\$ This is the optimal solution, since any longer solution could be reduced to this solution, which errors \$\endgroup\$
    – Jo King
    Commented Jul 3, 2018 at 23:17
  • \$\begingroup\$ This is also the only solution. \$\endgroup\$
    Commented Jul 4, 2018 at 8:52

R, 3 bytes


Try it online!

A name of an object is a valid program in R.

qrt is not the name of anything, so it returns an error.

q is the quit function

qr is the QR decomposition function

rt is the t distribution sampling function

qt is the t distribution inverse CDF

t is the transpose function

  • 2
    \$\begingroup\$ @pajonk but "r" is a continuous substring. Removing that leaves "qt" \$\endgroup\$
    – Orphevs
    Commented Jul 4, 2018 at 10:16
  • 4
    \$\begingroup\$ There is exactly one filthy program in R of length 3, and this is it! (the only single char valid programs are 0-9cqtCDFIT, any program must therefore start with cm, qf, qr, qt, ts or Im. The length three possibilities are qrf,qrm,qrt,qts and tsd and only one of these is filthy (the others can't be extended either to make them filthy as there are no functions rm*,rf*,ts*,sd*) \$\endgroup\$
    – JDL
    Commented Jul 4, 2018 at 13:14
  • \$\begingroup\$ @Orphevs my bad, misread the challenge. \$\endgroup\$
    – pajonk
    Commented Jul 5, 2018 at 5:30
  • \$\begingroup\$ Note that, following Arnauld's strategy (see 'Polyglot' answer), there are actually 101 filthy programs in R of length 3: this one, plus 100 more of the form 1 2 (where each of the two digits can be substituted with any of the other 9 possible digits). \$\endgroup\$ Commented Apr 12, 2022 at 10:43

Jelly, 4 5 6 7 8 10 11 bytes


Try it online!

Verify it.

Tries to add a string with an integer.

Some of the possible subprograms:

“a” is a string literal.

“a is the same string literal.

is the empty string.

“a”; concatenates "a" with itself.

...too many to enumerate them all.

  • 1
    \$\begingroup\$ Fortunately Jelly still allows you to error. \$\endgroup\$
    Commented Jul 4, 2018 at 8:51

Polyglot, 3 bytes

1 2

Works in:

  • JavaScript
  • Ruby
  • R
  • Octave
  • GHCi
  • Julia

In JavaScript, throws SyntaxError: unexpected token: numeric literal or a similar error.

All other strings are valid numeric literals (1, 2, or 12).

In GHCi this throws

<interactive>:1:1: error:
    • Non type-variable argument in the constraint: Num (t1 -> t2)
      (Use FlexibleContexts to permit this)
    • When checking the inferred type
        it :: forall t1 t2. (Num t1, Num (t1 -> t2)) => t2

This is because it tries to apply 1 to 2 as a function, however it cannot. When any part of this is removed it simply becomes a numeric literal.

  • \$\begingroup\$ Polyglot: R, Octave, Ruby, the Pythons... \$\endgroup\$
    – ngm
    Commented Jul 3, 2018 at 21:13
  • 1
    \$\begingroup\$ @ngm GHCi as well, however ` 2` errors in python. \$\endgroup\$
    – Wheat Wizard
    Commented Jul 3, 2018 at 21:29
  • \$\begingroup\$ I suspected that it was very generic. I've turned this into community wiki, so feel free to edit with all languages for which this works! \$\endgroup\$
    – Arnauld
    Commented Jul 3, 2018 at 21:32

Python 2, 2 bytes

Unexpected character after line continuation character


\ followed by any of 123456789 #
Try it online!

Invalid octal number


0 followed by any of 89
Try it online!

Unexpected Indent


or \t followed by any of 123456789\
Try it online!


Python 2/3, 3 bytes




Try it online!

In python "\f" is the same as "\x0c" and is a form feed character. This means that it indicates for a printer to go to the next line.

If a python expression starts or ends with \f, it is basically ignored so \f2 is a valid expression.

The 4 and 2 can be any number 0-9. However, for the first byte to be 0 is only valid in Python 2.7.15, as 02 was made a legal declaration of 2.

So the expression itself fails with a Syntax Error, because there are two numbers separated by a whitespace. However, any shortening either puts \f at the beginning or end, where it doesn't matter, or it creates 42 which is valid.

(It is worth noting that in IDLE this file opens looking like "42".)

Form feed explanation source: https://stackoverflow.com/a/26184126

  • 3
    \$\begingroup\$ This would be easier to understand if you used the actual code in the source without the \f. Here is a try it online link from which you can get a pre-formatted answer. \$\endgroup\$
    – Wheat Wizard
    Commented Jul 3, 2018 at 23:26
  • 1
    \$\begingroup\$ I have added it as a variant for clarification. Also, thank you for the suggestion of the link. \$\endgroup\$
    – The Matt
    Commented Jul 4, 2018 at 0:07

Dyalog APL, 5 bytes (SBCS)

~≢0 1

Try it online! or test all the possible programs

There sure are better boring answers, but this is the best non-boring one I've found

SBCS is required as Dyalog Classic seems to always have output in STDERR, making it unusable.


Zsh, 2 bytes


Attempt This Online!

Zsh is very good at producing errors, so this challenge is very hard.

  • : on its own is command which does nothing
  • # is a comment
  • :# is a single command, which doesn't exist, and therefore errors. (# is only a comment when it's at the start of a word)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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