One of your friends is struggling on a homework assignment. He needs a simple program which prints the first 404 natural numbers:

1 2 3 4 5 6 7 8 9 10 11 ... 401 402 403 404

Your challenge is simple: write this program for him.

However, your connection is terrible, so 1 random character is lost every time you send the program. To prevent this from breaking your program, you must make it so that removing any single character will have no effect: the program works, regardless. (The original program must also work.)

Because the connection is too poor to send large files, your code must be as short as possible.

TL:DR - make a radiation hardened program to output the numbers 1 to 404


  • The output may be a list of integers in any reasonable format (separated by spaces, newlines, commas, etc). However, your output must be consistent and not change when the program is modified.
  • Command line flags that contain logic, execute actual code, generate the number list, and so on, are banned.
  • This is , so the shortest submission (in bytes) wins!
  • 2
    \$\begingroup\$ Related \$\endgroup\$
    – FlipTack
    Dec 13, 2016 at 21:30
  • 3
    \$\begingroup\$ Are command-line flags subject to radiation (e.g. Perl's -p flag)? \$\endgroup\$ Dec 13, 2016 at 21:38
  • 6
    \$\begingroup\$ Can errors be ignored if the program still prints 1 - 404? \$\endgroup\$
    – jrich
    Dec 13, 2016 at 23:17
  • 4
    \$\begingroup\$ Maybe there should be a tag like radiation-hardering? \$\endgroup\$
    – Vi.
    Dec 14, 2016 at 18:10
  • 8
    \$\begingroup\$ Voting to close, we are not doing your homework for you XD \$\endgroup\$ Dec 16, 2016 at 9:05

15 Answers 15


JavaScript, 228 bytes




Evaluating code in a setInterval allows the program to continue even if there is an error. We make sure that the code passed will error out if any single character is removed. Template string syntax can be abused to call setInterval with a constant string without parentheses. Luckily, even if the template string is on the next line it still parses as a function call with such syntax.

The first issue we run into is that setInterval is a function, and thus if a character is removed and the program tries to call setInteval instead, it errors out. Of course, since there are two indentical invocations of the setInterval, we don't have to worry about it actually functioning correctly as long as we avoid the error. So, the first line defines every possible "misspelling" of setInterval to a valid function.

The first line works by assigning all of these "misspellings" to the function top=>4. Note the ES6 syntax, this simply takes a paramater named "top" and returns 4. Why "top"? Well, the first line must never throw an error even if a character is removed. If an = is removed to make top>4, this boolean expression will be valid since top is predefined in browsers, simply yielding false. If the 4 is removed, the function body simply becomes the first setInterval segment, and the second runs unharmed.

Now, all that is left to worry about is if a ` is removed.

If removed from the beginning, setInterval simply does nothing, evaluating to itself as its own expression. Then, the rest of the second line simply runs a single iteration of the loop, letting the other setInterval fragment finish the job. If removed from the end, the remaining backtick is picked up from the end of the comment.

The newlines are placed so that removal one will not affect program behavior, but they prevent errors in the case of some character removals such as the leading backtick.

  • 3
    \$\begingroup\$ I pondered what would break if one of the digits in a 405 were removed, but then I realized: nothing, because either all 404 numbers have already been printed, or the second loop will print the missing ones. Spectacular work. \$\endgroup\$ Dec 14, 2016 at 14:01
  • \$\begingroup\$ What happens if part of "top" gets lost? \$\endgroup\$
    – Scimonster
    Dec 15, 2016 at 12:11
  • \$\begingroup\$ @Scimonster It still parses as a function, returning 4, just with the unused parameter named "to" or "op" or "tp" \$\endgroup\$
    – jrich
    Dec 15, 2016 at 12:12
  • 1
    \$\begingroup\$ @jrich of course. Brain cramp. :P \$\endgroup\$
    – Scimonster
    Dec 15, 2016 at 12:14
  • \$\begingroup\$ What happens if you lose part of this? \$\endgroup\$
    – anna328p
    Dec 16, 2016 at 19:51

Pyth - 16 bytes

The basic idea behind this is that when you take a digit off of 404, it only makes the number smaller, so we just have to get the maximum of two 404's to ensure we have the right number. Obviously, there are a bunch more redundancies.

SSsetSS[404  404


SS                       First one does 1-index range, second one sorts, which is no-op 
 s                       If the e is there, this is no-op, if only t is there, it sums a one element list, which is the item
  et                     e picks last element in list, and if e is gone, then t gets you the list without the first element which is good enough when combined with s
   SS                    Sorting twice is no-op
    [                    Start list, this can't be two element because if we get rid of initial 4, the 0 becomes third element which neeeds to be captured
     404                 One of the 404's
     <space><space>404   Need two spaces for redundancy, because 404404 *is* bigger than 404

Try it online here.


Befunge-98, 37 bytes


Try it online!


Making radiation-hardened code in Befunge-98 isn't too bad, because you can set the "delta" (i.e. the step size of the instruction pointer) manually with x. So if set the delta to (2,0), from then on every other character is skipped and we can simply double up all commands. The tricky thing is getting 2 0 on top of the stack in a reliable way. We'll actually need 0 2 0 for the rest the program to work correctly, but we'll that for free. Here is how we do this:


Note that each digit pushes itself, so in the full program, there will be a start 2 0 which we'll simply ignore.

Consequently, dropping either the first or second character from the program is irrelevant because we won't use those digits anyway. Likewise, removing the third character is identical to removing the second, so we don't need to worry about that either.

Let's consider what happens in the other two cases. Dropping the fourth character:


Note the delta is set to (0,0). But this doesn't move the instruction pointer at all, so the same x is executed again immediately and this time pops the (2,0) and all is well (there are implicit zeros at the bottom of the stack for our later purposes).

Let's drop the fifth character instead:


Now the delta gets set to (0,2). However, there is still no horizontal movement, so the IP wraps immediately back to x and again, the correct delta gets set.

From this point onward we can basically ignore the character duplication as well as this initial part because it will always be skipped:


The ; is a sort of comment command which skips everything until the next ; is encountered. However, we jump over the first ; with # so only the part between the ; will be executed from that point onward.

1+    Increment the top of the stack.
:     Duplicate it.
'e    Push 101.
4*    Multiply by 4 to get 404.
`     Greater-than check. Pushes 1 once the top
      reaches 405, otherwise 0.
k@    Terminate the program that many times.
:.    Print a copy of the top of the stack (and a space).

05AB1E, 12 bytes



Normal code explanation:

X             # Pushes the number 1.
 X            # Pushes the number 1 again.
  440044      # Pushes the number 440044.
        Ô     # Connected uniquify.
         Ô    # Connected uniquify.
          Ÿ   # Inclusive range of the top two elements.
           Ÿ  # Inclusive range on the array, which leaves it intact.

This leads to the following golfed code: X404Ÿ, which is what we want to achieve.

The number 404 is generated by any of these variants:


The inclusive range works as following on two numbers:

`1 5Ÿ`             ->    [1, 2, 3, 4, 5]
[1, 5]Ÿ            ->    [1, 2, 3, 4, 5]
[1, 2, 3, 4, 5]Ÿ   ->    [1, 2, 3, 4, 5]

Which always makes the second Ÿ a no-op.

Uses the CP-1252 encoding. Try it online!


><>, 103 60 51 bytes

;?=*4o" e"n:ll<<
;?=*4o" e"n:ll<<

Tested here.

Uses the same tactic as this program. If a character is deleted in the first line, the 2nd line will still be run. If a character in the 2nd line is deleted, the v will move execution to the 3rd line, since the 2nd line is a character shorter. A deletion in the 3rd line has no effect on program control, as it is only execution after a deletion in line 2.

The program will also work in the event that a line break is deleted:

Case 1:

The 2nd line will be run.

               vv;?=*4o" e"n:ll<<
;?=*4o" e"n:ll<<

Case 2:

Both lines become one line with twice the instructions.

;?=*4o" e"n:ll<<;?=*4o" e"n:ll<<


The core of the program is the following. Note that a 1 is pushed on the stack already by the first line.

ll:n        Push length of the stack twice, duplicate, print as number
"e "o       Push 101, 32, output 32 as space
4*          101 * 4 is 404
=?;         Pop twice, if equal, halt
            (Execution wraps around)

><>, 42 38 34 bytes

Try it Online!

Thanks to @Martin Ender and @Teal Pelican for shaving off 8 bytes!

<<;?=*4o" e"lnll/
 ;?=*4o" e"lnll<

Similar to mbomb007's answer, but only uses 2 lines.

Instead of counting up from 1 to 404 using a single memory value, I continuously pushed the length of the stack. This made it so that I didn't need to put anything on the stack before the loop started, making things a lot easier.

The original code

The <s turn the IP around, and the / is a no-op, as the IP wraps around and continues along it's normal path. Thus, the relevant code is:

          lnll   Prints the size of the stack + 1 and pushes the stack size twice
     o" e"       Prints a space and pushes 101
   *4            Multiplies to get 404
;?=              If the number we just printed was 404, end the program

And this repeats.

The deletion

The big key here is the mirror /. It doesn't do anything if the second line is modified - only wraps back around to itself and is essentially a no-op. But if a character from the first line is removed, the line will shift down, so that the mirror hits the arrow <, leading into an identical, unmodified loop.

The only other significant deletion would be the \n character. This is also accounted for, as it produces this code:

<<;?=*4o" e"lnll/ ;?)*4o" e"lnll<

Now, we have just appended a copy of the original loop ;?=*4o" e"lnll to itself. As this is a loop, it makes no difference to the execution, and runs as if nothing had changed.

  • 1
    \$\begingroup\$ Really nice way to reduce it to 2 lines. The only problem I can see is that it's not 38 bytes but 42? Reducing the inner code to; ;?=*4o" e":n:+1l would reduce it down to 38 bytes though. This just places your 84* within the string " e" instead of separate. \$\endgroup\$ Dec 14, 2016 at 9:43
  • 1
    \$\begingroup\$ You can also replace the :+1 and the other : with one l each. \$\endgroup\$ Dec 14, 2016 at 10:06
  • \$\begingroup\$ Yes, thank you both! \$\endgroup\$ Dec 14, 2016 at 16:25
  • \$\begingroup\$ ;?=*4o" e"n:ll works too. \$\endgroup\$
    – mbomb007
    Dec 14, 2016 at 18:40

A Pear Tree, 34 bytes

The program contains control characters, so here's an xxd dump:

00000000: 7072 696e 7420 312e 2e34 3034 2327 108a  print 1..404#'..
00000010: af70 7269 6e74 2031 2e2e 3430 3423 2710  .print 1..404#'.
00000020: 8aaf                                     ..

A Pear Tree is basically a Perl derivative, with some "interesting" features. I threw it together as a joke (so that I could say that my polyglot printed a partridge in A Pear Tree; in fact, almost all programs do). However, it's Turing-complete, and actually kind-of good at this sort of challenge.

The feature that we mostly care about here is that A Pear Tree will only run a program if some substring of the code has a CRC-32 of 00000000. The code gets rotated to put the substring in question at the start. As it happens, the two (identical) halves of the code each have the CRC-32 in question (due to that suspicious-looking binary comment at the end), so if you delete a character from the source (breaking the CRC), the other half gets rotated to the start and the # sign near the end will comment the damaged half out, in addition to the binary junk.

Another feature makes the program slightly smaller: although A Pear Tree is mostly interpreted as Perl, it has some minor changes to make it work more like Python. One that's relevant here is that unlike Perl's print statement (which just runs the numbers together), A Pear Tree's print statement separates arguments with spaces and prints a final newline. That gives us nicely space-separated output, meaning that we don't have to waste bytes on formatting. (Note that you'll have to give the program no input; if the language receives input, it assumes by default that it's supposed to do something with it.)

Of course, this can't compete with actual golfing languages (nor would I expect it to), but I thought people might find it interesting.


Befunge 98, 34 bytes

Try it Online!



This works very similarly to my ><> answer, but instead of the mirror /, I use the turn left operation [ and then reverse the IP direction, which is functionally equivalent to a mirror in this case.

The original code

<<                 Reverses code direction, sending IP to right
               [   Turns the IP left, into the ^, which reverses it.
                   It then hits this again, turning left to go West. (No-op)
            :+1    Adds 1 to the sum
        *4e'       Pushes 404
     @k`           Ends the program if (sum > 404)
   .:              Prints the sum

The deletion

If something in the second line is deleted, it will shift over, and not affect the top at all.

If anything in the first line is deleted, the [ will send the IP into the <, which starts an identical loop (with the exception of 2j^^ which avoids the ^s used in tandem with the [)

Because there are 2 new lines, it makes no difference to the code if one is deleted (thanks to @masterX244 for this!)

  • \$\begingroup\$ what happens to empty lines in the code?. Maybe you could double the linefeed to make it immune, too \$\endgroup\$
    – masterX244
    Dec 14, 2016 at 12:04
  • \$\begingroup\$ You're completely correct @masterX244 thanks! Didn't think about that. \$\endgroup\$ Dec 14, 2016 at 16:17
  • \$\begingroup\$ lol, never used the language at all but for some reason a 6th sense gave me that idea... \$\endgroup\$
    – masterX244
    Dec 14, 2016 at 19:45

Befunge-93, 54 51 bytes

Thanks to Mistah Figgins for saving me 3 bytes.


Try it online!

This is essentially the same trick as was used in the Fault-Tolerant Hello World challenge. The first line starts by making sure there is a 1 on the top of the stack for the start of the sequence, and then one of the v arrows at the end of the line redirects the code path to the start of the main routine on line 2, executing from right to left.

Removing a character from the first line will just shift the v arrows across by one, but that still allows the code to redirect to the second line successfully. Removing a character from the second line causes the < arrow at the end of the line to shift out of the path of the v above it, so the code path will be redirected to the backup routine on line 3.

Removing the first line break does no harm, because that just moves the third line into place to replace the second line. And removing anything after the end of the second line will have no effect, because that's just the backup code.

  • \$\begingroup\$ The first line starts by making sure there is a 1 on the top of the stack... The first line is pretty sure of itself in that respect. Also, you can shorten the <code>_@#!</code> to _@#-` and put it before the printing to save 3 bytes. \$\endgroup\$ Dec 14, 2016 at 0:46

JavaScript + HTML + Stack Snippets, 167 158 154 bytes

Abusing the fact that JavaScript in Stack Snippets gets placed in a web page inside a <script> element.

or(x="",i=405,d=document;--i;)d[i]||(x=d[i]=i+' '+x);d.write(x)</script></script><script>for(x="",i=405,d=document;--i;)d[i]||(x=d[i]=i+' '+x);d.write(x)


Actually, 18 bytes


Actually is a stack based golfing language.

Explanation of the commands involved (as they work in the above context):

Numbers are indicated by round brackets () and lists by square brackets []

:         - pushes the longest string of characters in '0123456789+-.ij' as a numeric
k         - pop all the elements on the stack into a list [l] and push [l]
M         - pop [l], push max([l])
            pop (a), push (a)
R         - pop [l], push reverse([l])
            pop (a), push range([1,a])
S         - pop [a], push sorted([a])

Zsh, 26 bytes


seq  ???||seq *

Try it online!

Verify all mutations!


  • >404: create the file 404. This command is repeated twice because if one has had a byte removed, we need the other to still work. Ordinarily with > you wouldn't need the newline between them, but in the case the second > is removed, >404404 wouldn't create 404

  • ???: find a 3-character file name in the current directory (this will always find 404 because of the redundancy above)

  • seq: count up to that

  • ||: if that fails (happens if seq or ??? is mangled):

    • *: find a filename
    • seq: count up to it
  • The second newline before the first seq is necessary because otherwise >404seq would create two files, and then seq * would try to range between 404 and 404seq, which isn't a number

  • The second space in seq ??? is necessary because seq??? would fail to match, and for some reason the bit after the || doesn't get executed either (it's possibly a bug in zsh)

  • If any of the two |s are missing, the first seq is piped to the second; the second ignores its input, but still outputs as normal.


Vyxal, 11 9 bytes

-2 thanks to A username


Try it Online!

⁺e          # Push 202
  d         # Double ^ to get 404
   404      # Push 404 again
      ∴     # Take the maximum
               # If bytes are removed from either of the 404s, this ensures the intact one is pushed
               # If ∴ is removed, 404 is still at the top of the stack so it doesn't matter
       ɾ    # range(1, n+1)
        ƛ   # Map
               # If it's a number (ɾ removed), range(1, n+1) is used
               # Otherwise (it's a range), nothing happens here
  • \$\begingroup\$ 9 \$\endgroup\$
    – emanresu A
    Jul 29, 2021 at 4:14

Gol><>, 26 bytes


Try it online!

This is pretty simple, but there wasn't a Gol><> answer yet, and it scores pretty well.


Klein 000, 32 bytes


Try it online!

Klein XXX, 54 bytes

>>>             \\

Try it online!

Shamelessly reusing strategies from my fault tolerant "Hello world" solution.


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.