for the last one the result in either the if or else case is the same right? I could def see the condition being depth <= 0 to silently move past unbalanced parentheses though.
depth <= 0
Or, without the index:
replicateM_ 250 $ do
See this fork for testing with QuickCheck. It's not as completely-full-featured as what you are doing, but it writes quite a bit shorter. Testing itself is identical ( inputs are of length 1-250 instead of 3-250 because I was lazy ).
This is not a suggestion for this kata really, but you might like it and use it for future kata.
forM_ [1..250] $ \ i -> do
return () -- unnecessary if final line is `shouldBe` something -- that already returns ()
I have an unsafePerformIO in here for the random cases because I couldn't find documentation on how to do exactly 250 random cases. I'll take a rejection if the unsafePerformIO is bad practice, but I still need to figure out how to do a fixed number of cases which documents the test case (like it "testcase" $ do)
it "testcase" $ do
No, it isn't. That is just idiomatic Haskell.
CodeWars does not need another bad factorial kata.
This translation is also missing random tests. The original not having it ( if it doesn't ) is not an excuse.
I accidentally left a bunch of blank spaces at the bottom from when I was absentmindedly holding down the enter key
Forgot to remove unused Debug.Trace import.
I accidentally left in an unused Data.Bifunctor import
Don't ever actually do this lol
I'm realizing now that the tuple in go wasn't necessary and it could've been two separate arguments
How did you come up with this solution?
Is having the user return a Maybe Int too much to ask for a 7 kyu?
This comment is hidden because it contains spoiler information about the solution