A pristine program is a program that does not have any errors itself but will error if you modify it by removing any contiguous substring other than the entire program.
A crystalline program is sort of the opposite. It is a program which doesn't have any errors itself but will error if you modify it by adding any 1 character anywhere. We call these crystalline because adding an impurity will cause it to break.
Now a true crystalline program is quite hard to come by so in this challenge we will be just trying to get as close as possible.
You will write a program which does not error and count the number of 1 character insertions that also don't error. If your program were crystalline this number would be 0. Also count the number of total 1 character insertions possible.
Your score is then:
\$ \dfrac{\mathrm{number\,\,of\,\,nonbreaking\,\,insertions}+2}{\mathrm{number\,\,of\,\,total\,\,insertions}} \$
And your goal is to minimize this measure.
Specifics
Since different languages use different codepages and different ranges of characters, for this challenge a character is just any byte. The number of characters in your program is just the number of bytes it occupies and insertions are just that, the insertion of a new byte between any existing bytes or at the beginning and end of the program. You may select which characters you want to consider relevant for this challenge. When we insert any byte it will be one of those selected. The selected bytes must include:
- At least 96 distinct characters
- All characters used in your program
For counting, insertions are considered different if they produce different programs. For example if your program is
ABBA
, then inserting aB
after the firstA
, after the firstB
and after the secondB
all produceABBBA
, this counts as 1 insertion.A program errors if any of the following happens:
- The compiler exits with a non-zero return code when run on the program.
- The program exits with a non-zero return code when run.
- The compiler produces non-empty output to STDERR when run on the program.
- The program produces non-empty output to STDERR when run.
If your programming language of choice always triggers some of these options, ignore those specific options and treat them as non-errors. If your programming language of choice doesn't have a compiler just ignore options that mention a compiler.
#
to the end. \$\endgroup\$#
on the end. \$\endgroup\$