if expected is not actual:
test.assert_equals(actual, expected, f"For point ({x} {y})")
return
This code was intended to fail only one assertion per test case.
But the outside loop tested for sameness while the assertion inside tested for equality, so the solution that returned identical rectangle instead of the same rectangle got assertion right, and then early return - performing only one instead of large numbers of checks beating thus beating the tests.
Ok I'll keep adding in this post, and let you know when I'm finished.
#1
Mix of cycles and multiple bonds
Log
3-ethylcyclohexene:
CH2-CH2-CH-CH2-CH3
| |
CH=CH-CH2
{C: 8, H: 14}
=> the double bond should be between first and second C
CH2-CH2-CH-CH2-CH3
| |
CH2-CH=CH
There are more subtle mistakes like this in example tests. Should I let you know each time I find such small mistakes, or are these considered ok-ish? For instance:
"Two ramifications" test:
positions are swapped: should be 2-ethyl-3-methylpentane
first, the string is too short to conclude anything with that test (you're measuring the number of function calls rather than the actual "string work")
second, the actual speed will depend on the python version used. I don't know which one you used, but for instance trying with 3.7 (yeah, I know, but that's the only one I have access to on my current machine), replace is close to 3x faster on huge strings (like, x1000). And on small strings, it's also faster anyway, but the time consumption is so ridiculously low it's not even worth comparing: 5ms against 3ms...
not any(arr)
isO(n)
, but iffnot arr
, that'sO(1)
. but only in that case, true.True. But it's harder to spot the base case, here (in my mind, at least)
Note:
not arr
is actually O(1) so I wouldn't have phrased the sentencve like that (but maybe I'm just not following your train of thoughts)cool
I have republished the Kata and after fixing the major flaw in the tests all solutions published in so far have been invalidated. Sorry for that.
Marking issue as resolved.
OMG.
There was a bug in a testing loop.
This code was intended to fail only one assertion per test case.
But the outside loop tested for sameness while the assertion inside tested for equality, so the solution that returned identical rectangle instead of the same rectangle got assertion right, and then early return - performing only one instead of large numbers of checks beating thus beating the tests.
https://www.codewars.com/kata/reviews/6835f2368c715773ce65b8ef/groups/683617dc9efb9024f93cfa2e
Those 2 are the remaining ones in sample tests.
Ok I'll keep adding in this post, and let you know when I'm finished.
#1
yeah, make a list, please. I'll fix the whole thing at once.
This too was resolved many moons ago.
Marking this long-resolved suggestion as resolved.
There are more subtle mistakes like this in example tests. Should I let you know each time I find such small mistakes, or are these considered ok-ish? For instance:
"Two ramifications" test:
No, that's wrong.
This comment is hidden because it contains spoiler information about the solution
Loading more items...