Fault-Tolerant Hello World
Befunge, Score 0
I think I cracked it - no single character deletion will change the output.
Deleting any character from line 1 changes nothing - it still goes down at the same place.
Lines 2 and 3 are redundant. Normally line 2 is executed, but if you delete a character from it, the <
is missed, and line 3 takes charge.
Deleting newlines doesn't break it either (it did break my previous version).
No test program, sorry.
EDIT: simplified a lot.
vv
@,,,,,,,,,,,,,"Hello, world!"<<
@,,,,,,,,,,,,,"Hello, world!"<<
A short explanation of the flow:
- Befunge starts executing from top-left, moving right. Spaces do nothing.
v
turns the execution flow downward, so it goes down one line.<
turns the execution flow left, so it reads line 2 in reversed order."Hello, world!"
pushes the string to the stack. It's pushed in reversed order, because we're executing right to left.,
pops a character and prints it. The last character pushed is printed first, which reverses the string once more.@
terminates the program.
Perl, Score 0
(147 characters)
Here is my solution, which I managed to get from 4 down to 0:
eval +qq(;\$_="Hello, world!";;*a=print()if length==13or!m/./#)||
+eval +qq(;\$_="Hello, world!";;print()if*a!~/1/||!m/./#)##)||
print"Hello, world!"
It must appear all on one line to work; line breaks are for "readability" only.
It benefits from Perl's pathologically permissive syntax. Some highlights:
- Barewords that are not recognized are treated as strings. So when
eval
becomesevl
, that is not an error if a string is permissible at that point. - Unary
+
operator, which does nothing other than disambiguate syntax in certain situations. This is useful with the above, becausefunction +argument
(where + is unary) becomesstring + argument
(addition) when a function name is mangled and becomes a string. - Many ways to declare strings: a double quoted string
qq( )
can become a single-quoted stringq()
; a string delimited by parenthesesqq(; ... )
can become a string delimited by a semicolonqq; ... ;
.#
inside strings can eliminate balancing issues by converting things to comments.
The length of this can probably be reduced somewhat, though I doubt ugoren's solution can be beaten.
HQ9+
This will never fail to produce the intended result when a character is deleted so gets a score of zero.
HH
When do I start?