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
  • 6
    \$\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.
    Oct 1 '17 at 14:59
  • 1
    \$\begingroup\$ @WheatWizard When any two characters are removed, I'll edit that in \$\endgroup\$ Sep 16 '20 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
    Sep 16 '20 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
    Sep 16 '20 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\$ Sep 16 '20 at 22:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.