Alpha Decay is a kind of radiation decay where every time the atom "decays", it loses a helium nucleus (an alpha particle). This means that an atom loses 2 protons and 2 neutrons each time. Your task is to simulate this, including the problems that occur during alpha decay.

Given two integers as input, \$m\$ and \$p\$, where \$1 < p < m\$, count down in steps of 4 and 2 respectively until either \$m\$ or \$p\$ is equal to or less than 1. At this point, you should output the number which has not yet reached 1.

In order to mimic radioactive decay, however, your program should work when up to any 2 characters are removed from your program. These characters are chosen with uniform probability, and (obviously) chosen without replacement. "Up to" means that the number of characters removed can either be 0, 1 or 2, and your program should work when any number of characters between 0, 1 and 2 are removed.

By "work" it means that, your program, modified or not, should perform the task as specified. Programs may error, so long as the correct output is produced.

Input and output formats are liberal, so long as it's covered by the defaults, it's allowed.

The shortest code in bytes (without characters removed) wins!

Test Cases

m, p     => output
100, 20  => 60
101, 100 => 50
45, 2    => 41
2000, 80 => 1840
57, 23   => 13
80, 40   => 0
81, 40   => 1
81, 41   => 1
43, 42   => 20
  • 10
    \$\begingroup\$ Didn't downvote, but as far as I can see you are immediatly eliminating all the non-golfing languages, as the syntax would instantly be invalid if characters were to be removed. \$\endgroup\$
    – Ian H.
    Commented Oct 1, 2017 at 14:59
  • 1
    \$\begingroup\$ @WheatWizard When any two characters are removed, I'll edit that in \$\endgroup\$ Commented Sep 16, 2020 at 21:24
  • \$\begingroup\$ I'm confused as to why the second case outputs 50, shouldn't it output 48? And the 5th case 9 instead of 13? \$\endgroup\$
    – Wheat Wizard
    Commented Sep 16, 2020 at 21:58
  • \$\begingroup\$ If those test cases are just errora and I my understanding is correct, this should be a solution. I need to go to sleep though so I will check back tomorrow. \$\endgroup\$
    – Wheat Wizard
    Commented Sep 16, 2020 at 22:03
  • 1
    \$\begingroup\$ @WheatWizard Because, when I wrote this question 3 years ago, I went with 1 rather than 0. Not entirely sure why, but if I'd hazard a guess, I'd say because \$m\$ and \$p\$ represent mass and proton numbers, they can't reach 0 as all elements have at least \$m, p \ge 1\$ \$\endgroup\$ Commented Sep 16, 2020 at 22:06

1 Answer 1


Backhand, 99 bytes


Attempt This Online!

Backhand is a language created by Jo King in which, by default, the interpreter only reads every third character. This program uses the most basic form of , repeating each character several times, and removing any 1-2 characters results in the same characters being in the 0th, 3rd, 6th etc positions. I doubt there's a smarter way to do it.


This is the deduplicated version of the code. There's probably a better way to do control flow but I don't know how. There might also be a simple numerical formula for this, but I haven't figured out one.

II                                # Take inputs
  2-                              # Repeatedly, subtract 2 from one value
    $4-                           # And 4 from the other
       :1L                        # Is m at least 1?
           r:1L                   # Is p at least 1?
          )    (*                 # Multiply those together
                 !'B*  j          # If it's 0, loop ends, jump to index 72 (after loop)
                     6+           # Otherwise jump to index 6 (start of loop)
                        :1L       # If p <= 1
                           ]3*s$  #   then swap so m is on top of the top
                                h # Halt and output the remaining number.

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.