# Curiosity killed the cat?

Some people say curiosity killed the cat. Other say it was the box and poison. The RSPCA say Erwin Schrödinger needs to lose the right to own pets.

With animal rights activists outside his house. The cat murderer scientist Schrödinger has finally come up with his greatest invention. A special, radioactive mix of unobtanium and handwavium that can have any half life, and a single gram of the product is capable of killing any living creature. Unfortunately, when he tried to test it on his final cat: Bob, he forgot that cats have 9 lives, and so would need 9 grams to kill. With some water but no food, poor Bob will live exactly 1 week (7 days) if the product doesn't kill him first.

The task: Given an input of a mass in milligrams and a half-life in milliseconds - both integers which can exceed 2^31, write a program that outputs whether or not the mystery super product kills the cat, or if it's 1 week time limit expires first. Assume true/yes/1/anything specified in the answer is for when he does not die from starvation.

For the product to kill him, a total of 9 grams must decay. So out of a sample of 18 grams, 1 half-life must pass. If the sample contains less than or equal to 9 grams, this will never be achieved, and so it can be immediately assumed 1 week will pass before 9 grams decays.

You may assume:

• Bob dies the microsecond 9 grams has decayed.
• The change is mass due to decay does not matter.
• All days and times follow generally accepted earth time.
• The box Bob is sealed in is unbreakable and unopenable, so there is no chance of death from other causes.
• Oxygen is also no issue.
• If both happen at the exact same time either output is acceptable.
• All inputs should be below 2^63-1

Test cases:

Example:

18000 604800001


For 9 grams to decay, exactly 1 half life must pass (18000/2 = 9000 milligrams or 9 grams). 1 half life is 604800001 milliseconds, or 168 hours and 1 millisecond, or exactly 1 week and 1 millisecond. Since Bob dies of hunger at exactly 1 week, the output is false as he died from hunger just before the 9 gram product limit was reached

8000 40000 false

70000 800 true

18000 604800000 either

18000 604800001 false

18000 604799999 true

1 1 false

100000 1 true

1000000000 1000000000 true


Scoring: Naturally we want Bob's suffering to end quickly, and so a shorter half-life is best. Half-life and byte both end in E, so clearly the shortest byte count wins.

• You do realize that a radioactive substance never fully decays Aug 17, 2016 at 19:30
• I have no idea what we have to do here... Can you go through each step to find out if the output should be true or false? Aug 17, 2016 at 19:36
• Hi and welcome to PPCG! As others have said, this could use just a bit more clarification. If you address the points raised above, I think this could be a neat challenge, and it would get reopened. For future reference, we do have a Sandbox available so authors can get feedback on challenges before posting them to the main site. Aug 17, 2016 at 19:49
• Could you give us an equation for which outputs give True?
– xnor
Aug 17, 2016 at 23:15
• @xnor For half-life λ and mass m, m-m*(1/2)**(604800000/λ) > 9000 (or ≥, since the edge case can go either way).
– user45941
Aug 18, 2016 at 7:02

# Python 3, 33 bytes

lambda a,b:a-a*.5**(6048e5/b)>9e3


Explanation:

         6048e5         # number of milliseconds in 1 week
/b       # half-lifes per week
a*.5**(        )      # mgs of substance remaining after 1 week
a-                      # mgs of substance decayed after one week
>9e3  # return true if more than 9000mgs has decayed in 1 week


Try here

• Also 33 bytes: lambda a,b:2**(-6048e5/b)+9e3/a<1 Aug 20, 2016 at 8:44

## CJam (22 bytes)

q~dX.5@6048e5\/#-*9e3>


Online demo

### Dissection

A quick explanation of the maths: if the halflife is λ then after time t the proportion of the radioactive material remaining is (1/2)^(t/λ), so the proportion decayed is 1 - (1/2)^(t/λ).

q~d         e# Parse input, ensuring that the later division will use doubles
X.5@6048e5\ e# Rearrange stack to: m 1 0.5 6048e5 λ
/#-*        e# Div, pow, sub, mul, giving the total mass decayed after a week
9e3>        e# Is it OVER 9000! ?


# Fourier, 51 bytes

I have to admit that I don't fully understand this program... Mainly just a translation of TheNumberOne's Python code.

oI~M~NI~H604800000~G>H{1}{G/H^(M/2~Mi^~i)N-M>9000@o}


Note this is the first program that I've written for PPCG which uses @, the clear output function.

Try it online!

• Fitting user name...
– ojdo
Aug 18, 2016 at 11:20
• @ojdo Haha yes :D Aug 18, 2016 at 11:36

## Actually, 20 bytes

5╤:6048*/1½ⁿ1-*93╤*<


Try it online!

Explanation:

5╤:6048*/1½ⁿ1-*93╤*<
5╤                    10**5
:6048               6048
*              6048*10**5 (milliseconds in 1 week)
/             divide by half-life
1½ⁿ          (1/2)**(^)
1-        1-(^) (% of sample decayed after 1 week)
*       multiply by sample mass (mass decayed after 1 week)
93╤*   9*10**3 (9000)
<  is 9000 < sample mass decayed?


# Dyalog APL, 19 bytes

9E3≤⊣-⊣×.5*6048E5÷⊢


9E3≤ is 9000 smaller than or equal to

⊣- the left argument (mass) minus

⊣× the left argument times

.5*  ½ to the power of

6048E5÷⊢ 604800000 divided by the right argument (half-life)

No need for parentheses, as APL is strictly right-to-left.

TryAPL online!

• 19 bytes. That's dyabolical. Aug 18, 2016 at 13:13
• @matrixugly In this case, I'd ask why the other languages have so much fluff. I have exactly one character per "thing" in a quite normal-looking infix (like math) notation.