not arr is O(1), but in that case,any(arr) is alsoO(1). so not showing the base case doesn't make the solution slower. that's what I meant, and yes, I should have worded that more carefully, there are definitely situations where any(arr)is more computationally intensive than not arr.
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.
It's just an extra if statement. At one point I was considering having the case of the corrections be the majority case in the string - imagine how annoying that would've been. :-) Also, I wrote a whole set of test cases just for the case examples, and I don't want to redo those.
I spent more time thinking about the casing issue than anything else. There are clearly different possibilities, and it's not clear which is best. The reason why I went with the special case for one letter words is because I want one letter misspellings of two letter words (e.g. "we") to be corrected as follows:
"W" -> "We" (not "WE")
"E" -> "We" (not "we")
"w" -> "we"
"e" -> "we".
This is more natural to me, particularly (in the first two examples), if it's the first word of a sentence.
This comment is hidden because it contains spoiler information about the solution
ready
ready
If I'm not mistaken :
I don't see any drafts.
not arr
isO(1)
, but in that case,any(arr)
is alsoO(1)
. so not showing the base case doesn't make the solution slower. that's what I meant, and yes, I should have worded that more carefully, there are definitely situations whereany(arr)
is more computationally intensive thannot arr
.not any(arr)
isO(n)
, but iffnot arr
, that'sO(1)
. but only in that case, true.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.
This too was resolved many moons ago.
Marking this long-resolved suggestion as resolved.
Fixed (8 years later :D)
Sorry, I'm not understanding what you're referring to in
What's special about _ ? The sample tests don't have to have every example of punctuation.
I added examples like the 'ra' and 'frmo' cases to the sample tests.
It's just an extra if statement. At one point I was considering having the case of the corrections be the majority case in the string - imagine how annoying that would've been. :-) Also, I wrote a whole set of test cases just for the case examples, and I don't want to redo those.
I spent more time thinking about the casing issue than anything else. There are clearly different possibilities, and it's not clear which is best. The reason why I went with the special case for one letter words is because I want one letter misspellings of two letter words (e.g. "we") to be corrected as follows:
"W" -> "We" (not "WE")
"E" -> "We" (not "we")
"w" -> "we"
"e" -> "we".
This is more natural to me, particularly (in the first two examples), if it's the first word of a sentence.
Loading more items...