Your task is to create a program where if any one character is deleted, it will detect which character was deleted and then re-insert the deleted character in its own source file.
For instance, if your program is
RadiationHardened and it is modified to
RadiaionHardened, then your program must output that the 5th byte (0-indexed) was modified and then the program source must be
RadiationHardened immediately after execution.
Notes and rules
- You may assume that exactly one character was deleted in the source code before execution. Behavior for the unmodified program is undefined.
- You may assume the changed byte will be deleted, not transposed, inserted, or replaced.
- In the case of a run of multiple of the same character, you may report either the first or the last index of the run, but be consistent about which you use. For example
baaadbeing deleted to
baadcan report either 1 or 3 (zero indexed), but must be the same throughout the entire program.
- You do not need to write out the entire source to its own file. You need only re-insert the deleted byte.
- Unlike the typical rules for radiation-hardened quines, detecting the changed byte from reading the program's own source code is fair game.
- You can output the changed byte index through any reasonable format. Be consistent about whether it is 0-indexed or 1-indexed or any other notation. You may even output a number within a template string.
This is code-golf so the shortest program wins.
EDIT1: changed requirement from replacement to deletion
EDIT2: added rule for runs of duplicates