The cops created code challenges which result in certain wildly incorrect answers despite correct math. Choose an uncracked, not safe formula from the cop thread.
Your task is to find an incorrect answer and describe its underlying cause. The challenge author has the responsibility to confirm whether the explanation is valid, but the incorrect answer does not have to be the same one the challenge creator had in mind.
Scoring, Rules, and Notes
- Score 1 point for each successfully cracked answer.
- If the error is caused by a particular usage of an external library (or specific version of it), it is sufficient to simply state that there is a known bug with a particular usage of the library used by the cop challenge. Link to a relevant bug report or article.
- This is to avoid having to pour through potentially millions of lines of source code in libraries (which may be closed source anyway) to find the exact cause of the error.
- Formula: The Pythagorean Theorem, \$ a^2 + b^2 = c^2 \$
- Inputs: 2 nonnegative real numbers
- Off by more than either input number
- Affects most inputs
- WSL (Ubuntu 18.04) on Windows 10, Python 3.6.9
def badpythag(a, b): a2 = (a / 1e200) ** 2 b2 = (b / 1e200) ** 2 return math.sqrt(a2 + b2) * 1e200
This will fail on many inputs (e.g. 3, 4 => 0, but should be 5) due to floating point underflow and return 0. The answer is correct with very large inputs e.g. 3e150 and 4e150, however.