><> (Fish), 145 107 bytes
This answer uses ><>'s jumping instruction to fix the problem.
!<0078*+00~..>0[!."r43a*+8a+&{ee+00&1-:&(?.~~ol?!;4b*0.0f<>0['r3d*159*+&}7a*00&1-:&(?.~~ol?!;68a*+0.0+*a58
This quine actually contains two different quine generators. It starts with some jumping logic and by default uses the left quine. If a character is removed from the jumping logic or from the left quine, the program jumps to the right quine.
You can try it here
Explanation
The code can be dissected into a few parts:
A: !<0078*+00~..>0[!.
B: >0[!."r43a*+8a+&{ee+00&1-:&(?.~~ol?!;4b*0.
C: .0f<
D: >0['r3d*159*+&}7a*00&1-:&(?.~~ol?!;68a*+0.
E: .0+*a58
Explanation of the different parts:
- A: Jumps to the right of C. If any character is deleted from from A,
this jumps to the left of D or the right of E, triggering the second
quine.
If any character is deleted from B or C, the code is shifted 1
character to the left, causing this to jump to the left of D.
- C: This code jumps to the left of B.
- B: Quine #1
- D: Quine #2
- E: Jumps to the left of D
Explanation of the quine (with #1 as example):
Once the instruction pointer reaches either of the quines, you're certain that that quine is completely intact.
>0[!. //Fix the instruction pointer's direction and empty the stack (The '!.' is a leftover from codepart A)
"r43a*+ //Start reading all of the code and add the '"' character to the stack
8a+& //Because the quine started reading at the 19th character instead of the first, the stack has to move 18 characters.
//This part saves the number 18 to the register.
{ee+00&1-:&(?. //Move the stack one to the left, decrease the stack by 1. If the stack is not empty yet, jump back to the start of this section.
~~ //Clean the temporary variables from the stack. It should now contain the whole quine.
ol?!;4b*0. //Print the first character from the stack. As long as the stack isn't empty, jump back to the start of this section.
Is an empty program valid? – Loovjo – 2016-02-20T07:06:43.570
4
@Loovjo No.
– Martin Ender – 2016-02-20T09:55:36.107Does the original program need to be a quine? I.e. in the example, is it enough that
A
outputsA
andB
outputsB
, or is it also necessary thatAB
outputsAB
? – feersum – 2016-02-21T04:26:50.2333@feersum The challenge states "Make a quine where...", so
AB
should outputAB
. – Mego – 2016-02-21T04:54:27.0371@Mego I know it says that, but specifications are not always so precise, and it is not indicated in the examples. – feersum – 2016-02-21T05:20:54.637
4@feersum "Make a quine" means make a quine. "The difference between this and a radiation-hardened quine..." means that the only difference is that the program with any one byte removed results in a quine, not a program that prints the original program's source. There is no ambiguity here. – Mego – 2016-02-21T05:24:34.063