Ad
  • Custom User Avatar

    When trying to Submit solution I'm getting this, even though after clicking Run Tests button the tests are passing. Anyone else experiencing this?

    /tmp/haskell116513-13-w02v09/Codewars/Kata/BouncingBall/Test.hs:2:8:
    Could not find module `Codewars.Kata.BouncingBall'
    Use -v to see a list of the files searched for.
    
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Extraneous words in the initial sentence of the description: "In this Kata you need to will need to write two methods."

  • Custom User Avatar

    Cool. The degree of similarity is astonishing :)

  • Custom User Avatar

    I like this kata. But I've got problem with the fact that the naive Haskell implementation of "pretty" (using ++), which has potentially quadratic complexity (and incidentally is also the way that most solutions are implemented) is promoted as best practice solution. In order to spread the word and promote good Haskell programming practices I would:

    1. add some test case which would make tests with naive implementation (using ++) fail with timeout.
      e.g:

    bigRazor = foldl f (Lit 0) [1..10000] where f r i = Add r (Lit i)
    -- and the test would for example just check the lenght of the resulting String

    1. Mention in the assignment that the naive implementation using (++) would not be accepted and point people to some simple example of the proper way to implement pretty (= basically Show instance) for Razor, e.g. https://www.haskell.org/tutorial/stdclasses.html
  • Custom User Avatar

    In that case the instructions should be changed from "the string CONTAINS the word hallo .." to "the string STARTS WITH the word hallo" to remove the ambiguity.

  • Custom User Avatar

    Haskell test cases are incomplete.
    I noticed one user had solution which was incorrect, but still it passed the tests:
    isBalanced :: String -> Bool
    isBalanced xs = count '(' xs == count ')' xs
    where count c xs = length $ filter (== c) xs

    --> A test case should be added which hase the same number of L/R parenst, but which are not balanced, e.g. ")("

  • Custom User Avatar

    The same problem here, seems like a bug in the test.
    Falsifiable (after 12 tests):
    expected: False
    but got: True
    "foo bar bar salut textbook"

  • Custom User Avatar

    Nice. If you start the infinite list with 0 you can replace (i-1) with i, making the solution even more conscise :-)

  • Custom User Avatar

    No need for the cases "accum [] = []" and "rep 0 c = [toUpper c]"

    because replicate 0 _ = [] and intercalate _ [] = []

    Otherwise nice solution.

  • Custom User Avatar

    Cool, I love these things that lazines brings :) Thanks for explanation.

  • Custom User Avatar

    Will this not break with empty list?
    λ> minimum []
    *** Exception: Prelude.minimum: empty list

  • Custom User Avatar

    Though this solution is clever, note, that "concatMap inits . tails" produces a list of substrings that is quadratic in the lenght of input arguments. To answer this question it might be sufficient to look for substrings of length 2 of s1 in s2.

  • Default User Avatar

    In my opinion (backed by Wikipedia https://en.wikipedia.org/wiki/Vowel#Written_vowels) there are 6 vowels in latin alphabet. Namely: a, e, i, o, u, y.

    In Haskell test fixture there are some test cases containing the letter y ("bialy"), but the assert says the vowel indexes are [2,3], whereas they should in fact be [2,3,5].
    In other words letters 'y' and 'Y' should be considered vowels by the test fixtures, but they are not.
    But it might be some linguistic confusion from my side :-)