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.

  • Custom User Avatar

    By the way, you probably use an exponential algorithm to get your result and therefore have O(2^n) instead of O(n).

  • Custom User Avatar

    I can't say better:-)

  • Custom User Avatar

    This means your code is not optimal enough.
    When you press "Run tests", you run the simple tests, which are editable.
    When you press "Submit", you run the validating tests, which you cannot edit and which may be quite heavy. If you get the 6000ms error, your code is just too slow, and you have to refactor it so it manages to run the submission tests within 6 seconds.

    https://github.com/Codewars/codewars.com/wiki/Error-messages:-Submission-timed-out#huh-it-says-now-process-took-more-than-6000ms-did-they-change-the-message

  • Custom User Avatar

    hi, am new here. when i press test button it is success and takes 16ms, if i press submit button i get an error because it is taking more then 6000ms. I dont get it :)