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
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.
m-m*(1/2)**(604800000/λ) > 9000(or
≥, since the edge case can go either way). \$\endgroup\$