Stax, 11 bytes (Score of 4)
'''cc'~~'dd
Run and debug online!
It is my honor to have the first (chronologically) answer to this challenge with a score higher than or equal to 4. Maybe the score can be even higher though.
In Stax, a string literal that is composed of a single character is written with '
, so '', 'c, 'd, '~
are all string literals. The corresponding commands for c
d
and ~
means duplicate the top of the main stack, pop the top of the main stack, and pop the top of the main stack and push to the input stack, respectively. For this challenge, input stack does not affect output and is not important, hence we can say d
and ~
are identical.
Explanation
It is best to divide the code into several parts and consider them separately.
When it is not tampered with, '''cc
pushes a literal '
and a literal c
to the main stack, and duplicates the top, so the stack would be (from to bottom) c,c,'
.
When not tampered with, '~~
pushes the literal ~
and then pops it (and push to the input stack), which is basically a no-op for the main stack.
When not tampered with, 'dd
pushes the literal d
and then pops it, another no-op for the main stack.
At the end of the program, since no explicit output is done, the top of the main stack will be implicitly printed out.
If the program is running as-is, the final stack is still c,c,'
and will output c
.
If the first part becomes ''cc
, then we have a literal '
, and two copy instructions, the final stack will be ',','
. Given that the two other parts are no-op, the result will be '
.
If the first part becomes '''c
, the result is basically the same with the untampered one, but the c
is not duplicated. So the stack will be c,'
. After two no-op's the top of the stack is c
.
So we can detect radiation in the first part.
The second part and the third part work in exactly the same way. I will take the third part as an example.
If the third part is tampered with, then the first two parts are kept as-is and the stack before running the third part is c,c,'
If the third part becomes 'd
, a literal d
is pushed to the top of the main stack and nothing further is done. The top of the main stack is now d
which will be output.
If the third part becomes dd
, two elements are popped from the main stack and now the top of the stack is '
and is output.
Hence we can detect radiation in the third part. For the same reason we can detect radiation in the second part.