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 baaad being deleted to baad can 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 so the shortest program wins.

Good luck!

EDIT1: changed requirement from replacement to deletion

EDIT2: added rule for runs of duplicates

  • 4
    \$\begingroup\$ This is a lot harder than handling arbitrary deletions. Most non-esolangs are obviously out (it's usually impossible to write any program that remains syntactially valid under any one-byte modification). Even Fungeoids are mostly thwarted (they can't do anything if the 0th byte is changed into a quit program command). I thought maybe one of two IPs could survive in something like Fission but its * command kills all of the IPs. Cardinal can't do it either, because of @. \$\endgroup\$
    – Lynn
    Feb 23, 2019 at 19:50
  • \$\begingroup\$ This might be turned into a code-challenge where each program is allowed to declare a list of bytes that are protected against radiation (but no more than -- say -- 50% of the total size). A simple scoring system could be to count each radiation-protected byte as 10 bytes, or something like that. \$\endgroup\$
    – Arnauld
    Feb 23, 2019 at 22:48
  • \$\begingroup\$ (But that may lead to some trivial and not very interesting answers.) \$\endgroup\$
    – Arnauld
    Feb 23, 2019 at 22:54
  • 1
    \$\begingroup\$ @JoKing, reporting either as missing is fine, as long as it's consistent. \$\endgroup\$
    – Beefster
    Feb 25, 2019 at 16:56
  • 2
    \$\begingroup\$ "You may require the file to be named a certain name and be run from a specific directory" - be careful, someone can just require that the filename be the correct program... \$\endgroup\$
    – ASCII-only
    Feb 28, 2019 at 22:55

2 Answers 2


Befunge-98 (FBBI), 344 296 248 bytes


Try it online!


Befunge-98 is the first esoteric language that I could find that was both 2D and had file output. This is a full solution (with a trailing newline) stored in a file named as a tab character. It outputs as 0-indexed, and outputs the first index in a run of characters (though there's only ever pairs).

There's a few golfs to be made, especially as there are 15 no-ops in the code, now just one no-op! I will be working on making this shorter, with the goal of getting to or below 200 bytes.

  • \$\begingroup\$ Oh wow! I didn't think this was possible \$\endgroup\$
    – MilkyWay90
    Mar 1, 2019 at 2:36

Unefunge-98 (PyFunge), 118 bytes


Try it online!


While golfing my Befunge-98 answer, I realised I could save some bytes by porting it over to Unefunge, since I would only have to worry about the one dimension rather than the two. This also opened up a lot of possible shortcuts and golfs, which made the new solution much much smaller.

Explanation (de-duplicated):

2x        Set the delta of the movement to 2
          This means the pointer moves 2 cells every step
          This will also initialise a counter as 2 (unless a 2 has been removed)
  0       Create the cell counter  (This will be stored at cell 0)
   #r     Enter the loop
     3k:                 Create 3 more copies of the counter
        g                Get the cell at the counter's position
         \1-p            Put it in the cell before that position
             2+0p        Add 2 to the counter and put it in cell 0
                 g       Get the cell at the counter's position
                  \1+g   Get the next cell
                      -!z!2*      If they are identical, push two, else 0
                            --    Subtract it from the total counter
                              0g:g84*-!   If the next character is a space
                                       2+j  r   Exit loop
                                         j#'    Else jump back to the start

Once the loop is over
+      Add the negative counter to the total counter
 .     And print
   '20p          Replace the 2 in cell 0 that was overwritten
             o   Write to a file named
            9    Tab
       01-       The cells from -1 to
  g              The total number of cells
              @  And exit the program

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.