Beta

Sum of primes

Description
Loading description...
Algorithms
  • Please sign in or sign up to leave a comment.
  • Voile Avatar

    This kata boils down to "finding the fastest prime sieve implementation", which is not a good idea at all (not to mention being a duplicate of many existing katas).

    Well, at least {-# OPTIONS -O3 #-} exists for GHC 8.2...

  • Voile Avatar

    The description and sample tests are kinda unclear. More illustrative examples than just should return 119 given [(4,5),(6,9),(10,10)] as input should be added.

  • JohanWiltink Avatar

    This comment has been hidden.

  • minib00m Avatar

    Tests are expecting sumPrimes function, but final checker expects sumOfAnsweredQueries function. Second, what does this guarantee mean? "1 <= x <= min(250000, length P)" Third, is it really that hard to solve this problem? Calculating primes up to 49979687 (this is last prime required by the task - 3000000th) is taking waaay to long... At first i way happy to see some algorithmic task in here, but now i feel it's very restrictive or i don't understand something.

    • MarcoXerox Avatar

      Sorry for the mistake. I believe there are no tests expecting sumPrimes function. In fact my final solution does not have such a function name. The guarantee is misleading and I have amended the Kata description. Note that every element of P is less than 3 million. My apologies for poor description.

      Issue marked resolved by MarcoXerox 9 years ago
    • minib00m Avatar

      When you run tests (not submit) then you will get "sumPrimes is not in the scope". This is what i see: "do sumPrimes input1 shouldBe expected1"

      Moreover, can you give a little hint? My solution is timing out on calculating "3000000th" prime: it is: 49979687. How advanced algorithm is sufficient to make it in the time?

    • MarcoXerox Avatar

      I don't know why I cannot edit the example test cases after re-publishing several times. You need to calculate all primes less than 3 million. That is what P[i] <= 3000000 for all i means.

    • MarcoXerox Avatar

      This comment has been hidden.