It would be worthwhile to include handling of edge cases at the beginning of the solution. You need to make sure that the function handles edge cases correctly, such as when a or b is 1.
An example of handling edge cases:
def number_of_sets(a, b):
if a == 1 and b == 1:
return 1 # Case (1, 1, 1) satisfies the conditions
I've come up with a solution (python) that seems to work for this problem, I pass the test phase but when I do the attempt, it fails seemingly randomly with this error :
Traceback (most recent call last):
File "/workspace/default/src/codewars-test/codewars_test/test_framework.py", line 111, in wrapper
func()
File "tests.py", line 33, in random_tests
test.assert_approx_equals(cf_value(arr), expected)
File "/workspace/default/src/codewars-test/codewars_test/test_framework.py", line 84, in assert_approx_equals
div = max(abs(actual), abs(expected), 1)
TypeError: bad operand type for abs(): 'NoneType'
The tests are then completly stopped.
I do return None in some of my code, but it is intended and within the rules (as far as my understanding goes). What surprises me is that this error do not look like an intended response from the test but rather that the assert does not expect a None return, resulting in the testing framework crashing as a whole.
C Translation (author inactive).
It would be worthwhile to include handling of edge cases at the beginning of the solution. You need to make sure that the function handles edge cases correctly, such as when a or b is 1.
An example of handling edge cases:
def number_of_sets(a, b):
If we're evaluating continued fraction, why isn't the returned value a
Fraction
?I've come up with a solution (python) that seems to work for this problem, I pass the test phase but when I do the attempt, it fails seemingly randomly with this error :
The tests are then completly stopped.
I do return None in some of my code, but it is intended and within the rules (as far as my understanding goes). What surprises me is that this error do not look like an intended response from the test but rather that the assert does not expect a None return, resulting in the testing framework crashing as a whole.
Why is the expected result 0?
I would suggest to change kata's category from "Puzzles" to "Basics".