Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Haskell translation
I think that can be
property $ \ (NonEmpty xs) -> do
, which would have automagic shrinking ( at the price of showing a newtype'd value in the failure message. you could prevent that by usingBlind (NonEmpty xs)
and a custom message withTest.HUnit.assertEqual
, which is probably a good idea for an 8kyu kata ).Generally, showing the input in a custom failure message is a good idea for a white kata.
Approved
if you increase the tolerance you won't need to invalidate existing solutions
https://github.com/codewars/hspec-codewars/blob/3b7d3602532a1cd44de7ac39adf45bcae17caf30/src/Test/Hspec/Codewars.hs#L125
Python fork
Haskell fork
This fork fixes a few issues:
shouldBeApprox
instead ofshouldBe
Float
toDouble
Regarding the type change, double precision floats are needed as the order of summation on single-precision floats can differ by amounts greater than the tolerance needed by
shouldBeApprox
.For example:
This comment is hidden because it contains spoiler information about the solution
"my mathematical brain hates that I need to round this"
It isn't rounding, casting to int chops the decimal bit off.
The description states that the input should be an NxM array, but the random tests for Python can produce arrays with rows of differing lengths.
The tests should limit the imports from the solution to only those being tested, as any defined helpers may clash with names in the tests.
I appreciate the use of
fix
, but doesn't using(++)
inappend'
kinda defeat the purpose?Python: No random tests
Even though the tests don't test for this, you should probably replace
'|'.join(forbidden_words)
with
'|'.join(map(re.escape, forbidden_words))
to avoid errors if any word in
forbidden_words
contains regex metacharacters.While it's not the simplest, I'm proud of the time complexity of my solution. Once the trie is populated, each call of
check1800
runs in constant time, since phone number length is constant.Randomized testing in Haskell (and maybe other languages) can result in the following:
The description lacks enough detail to determine sorting behavior between letters and characters whose ASCII value falls between the upper and lowercase letter ranges:
[\]^_`
Loading more items...