Ad
  • Custom User Avatar

    I would think generally, Haskell code would run faster than python, due to the fact that it is compiled. Python is not known for being the quickest running language, until you start using things like pypy.

    It's not under 21 ms, runs around 800ms currently

  • Custom User Avatar

    @g964:

    You can't compare the time between different languages at Codewars.

    You can. runhaskell Main.hs and/or ghc --make Main.hs && ./Main will always have a greater overhead than python main.py, since GHC compiles everything and loads its RTS.

    The Haskell tests are a bit less difficult than the Python tests because Python is usually fast.

    That's bogus. Given that your hidden tests use 1200 * x, where x is an arbitrary positive integer, it's rather likely that QuickCheck will generate several values that are larger than 83. Also, Python has only 25 random tests, where Haskell has 100.

    PS: I think this kata is not an easy one because of big numbers.

    It is easy. Even a O(n) implementation will succeed. However, a O(2^n) implementation is guaranteed to fail.

    @TheEndIsNear: Add a test case for 100000 to your own test cases. Check whether your algorithm still completes in 21ms.

  • Custom User Avatar

    Look at the post below, you will understand that your code in Python isn't fast enough. You can't compare the time between different languages at Codewars. Maybe Haskell is rather lengthy to begin but when it has begun, it goes faster... Who knows? Another possibility: the Haskell tests are a bit less difficult than the Python tests because Python is usually fast.
    Anyway it's not a Kata issue, it's an issue of your coding. Better the calculation of your Fibonacci and you'll succeed.
    PS: I think this kata is not an easy one because of big numbers.

  • Custom User Avatar

    Ok, I have written code for this Kata in Python, and have used arrays to compute the Fibonacci numbers. When I use the default test cases, they complete in 21ms.

    A coworker of mine has completed this challenge using Haskell, and is using a less efficient way to compute fibonacci, and it takes 2430 ms.

    When I submit my code, I get the error "Process was terminated. It took longer than 6000ms to complete." But my coworkers code, even though it takes much longer to run, is accepted.