26
2
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 – 2018-07-03T14:49:24.157
@JungHwanMin If the language enforces balanced parentheses I would suspect that it would be impossible. – Post Rock Garf Hunter – 2018-07-03T14:53:39.123
@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 – 2018-07-03T15:11:51.707
@JungHwanMin Sorry. It may or may not. We only care about continuous strings. – Post Rock Garf Hunter – 2018-07-03T15:14:30.000
What's the intention of the first paragraph of the question ("this is strings of bytes, not characters")? Is it to say individual bytes have to be removable and the program should still work? For eg., if I used
π
in my program, does it have to work when individual bytes of it (0xcf and 0x80) are removed? – sundar - Reinstate Monica – 2018-07-03T20:10:31.617@sundar The intention of the first paragraph is to make clear that it doesn't matter what characters your program encodes, only what is actually encoded. If you use
π
in your program you are using two bytes, it doesn't matter that they only display as one character under some encodings, they are separate bytes, and are treated no different than for examplea%
which is also two bytes. – Post Rock Garf Hunter – 2018-07-03T20:13:33.807Does leading or trailing whitespace count towards the bytes? – ngm – 2018-07-03T20:31:45.463
@ngm Yes it does. – Post Rock Garf Hunter – 2018-07-03T20:34:00.480
"For this challenge an error is a non-empty output to STDERR". Compiler errors count as well, right? – Jakob – 2018-07-03T20:48:33.920
@Jakob Yes, both compiler errors and runtime errors both count. – Post Rock Garf Hunter – 2018-07-03T20:53:33.377
3This script generates all the programs necessary to check – Conor O'Brien – 2018-07-03T22:49:54.627
@ConorO'Brien maybe there is a way to do that with Bash on TIO to test them automatically? I don't know Bash or if there is a
try
andexcept
construct. – dylnan – 2018-07-04T04:11:33.383@dylnan Bash can check for exit code, but that won't work for languages which doesn't use exit code to indicate error. However if it's possible to do it natively it's often faster. – user202729 – 2018-07-04T08:58:21.940