Fixed tests that disallowed correct answers #1896
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The tests assume that there can be only one way to solve the problem: if the number is even, divide it by 2 and if the number is odd, multiply it by 3 and add 1.
Multiplying by 3 and adding 1 can cause an overflow, which the tests accommodate by allowing
None
as a correct response wheneveru64
overflows occur.The problem is that
None
is considered to be the only correct response in that case, when every nonzerou64
has a correct answer that can be put intoSome
. For example, overflow can be avoided by converting the inputu64
into au128
and then getting the result usingu128
arithmetic.This commit corrects the tests so that either
None
or the correct answer is allowed whenu64
overflow can occur. All code that already passed the old tests will also pass the corrected tests.