# Filthy and Unique

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.

• 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. – JungHwan Min Jul 3 '18 at 14:49
• @JungHwanMin If the language enforces balanced parentheses I would suspect that it would be impossible. – Sriotchilism O'Zaic Jul 3 '18 at 14:53
• @CatWizard so a filthy program does not error when a continuous substring of characters (i.e. not continuous set of bytes) is removed, correct? – JungHwan Min Jul 3 '18 at 15:11
• @JungHwanMin Sorry. It may or may not. We only care about continuous strings. – Sriotchilism O'Zaic Jul 3 '18 at 15:14
• This script generates all the programs necessary to check – Conor O'Brien Jul 3 '18 at 22:49

# Unary, 14 bytes

123456789ABCDE


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.

• This is the optimal solution, since any longer solution could be reduced to this solution, which errors – Jo King Jul 3 '18 at 23:17
• This is also the only solution. – user202729 Jul 4 '18 at 8:52

# R, 3 bytes

qrt


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

• @pajonk but "r" is a continuous substring. Removing that leaves "qt" – Orphevs Jul 4 '18 at 10:16
• 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*) – JDL Jul 4 '18 at 13:14
• @Orphevs my bad, misread the challenge. – pajonk Jul 5 '18 at 5:30

# Jelly, 4 5 6 7 8 10 11 bytes

“a”;⁽PFð+µU


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.

• Fortunately Jelly still allows you to error. – user202729 Jul 4 '18 at 8:51

# Python 2, 2 bytes

### Unexpected character after line continuation character

\0


\ followed by any of 123456789 #
Try it online!

### Invalid octal number

08


0 followed by any of 89
Try it online!

### Unexpected Indent

 0


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

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

• Polyglot: R, Octave, Ruby, the Pythons... – ngm Jul 3 '18 at 21:13
• @ngm GHCi as well, however  2 errors in python. – Sriotchilism O'Zaic Jul 3 '18 at 21:29
• 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! – Arnauld Jul 3 '18 at 21:32

# Python 2/3, 3 bytes

4\f2


OR

4\x0c2


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

• 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. – Sriotchilism O'Zaic Jul 3 '18 at 23:26
• I have added it as a variant for clarification. Also, thank you for the suggestion of the link. – The Matt Jul 4 '18 at 0:07

# Dyalog APL, 5 bytes (SBCS)

~≢0 1


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.