Ad
  • Custom User Avatar

    Two of sample tests are incorrect in Haskell translation:

    it "abcdxg" $ do
      middlePermutation "abcdxg" `shouldBe` "cgxdba"
    it "abcdxgz" $ do
      middlePermutation "abcdxgz" `shouldBe` "dczgxba"
    

    Should be cxgdba and dczxgba

  • Custom User Avatar

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

  • Custom User Avatar

    LYAH is quite amazing. It has rather gentle learning curve, gradually introducing new concepts without intimidating readers with too much abstract math. Besides it's free.

    Another good one is Real World Haskell, which is also available for free online.

    I've also heard great things about Haskell Book, which is in early access now. Haven't read it myself yet, though.

    Here is a great repo listing many more Haskell learning resources: https://github.com/bitemyapp/learnhaskell

  • Custom User Avatar
  • Custom User Avatar

    Suppose there are no primes in [m..n]:

    • find (\(a, b) -> b-a == g) . uncurry zip . (id &&& drop 1) . filter isPrime $ [m..n]
    • find (\(a, b) -> b-a == g) . uncurry zip . (id &&& drop 1) $ []
    • find (\(a, b) -> b-a == g) . uncurry zip $ ([], [])
    • find (\(a, b) -> b-a == g) []
    • Nothing

    Which is exactly what supposed to happen:

    function should return the first pair of two prime numbers spaced with a gap of g between the limits m, n if these numbers exist otherwise Nothing.

  • Custom User Avatar

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

  • Custom User Avatar

    Yep, works fine now. Thanks.

  • Custom User Avatar

    Haskell version of test is asking for meanVar:

    .../Codewars/G964/Rainfall/Test.hs:74:13:
        Not in scope: `meanVar'
    
  • Custom User Avatar

    Haskell:
    Experiencing the same issue as BalinKingOfMoria and jhfung.

    Also:

    Falsifiable (after 3 tests and 1621 shrinks): 
    expected: Two (-8.707266183090575e161) 2.9056140599581754e160
     but got: Two 0.0 (-8.416704777094758e161)
    5.0e-324
    4.1584046815504265e-162
    0.0
    

    Meanwhile:

    ax^2 + bx = 0

    x(ax + b) = 0

    x = 0 or ax + b = 0

    x = 0 or x = -b/a

  • Custom User Avatar

    In Haskell should probably also hide Numeric module or just readInt and readDec from it.