Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
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...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.This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
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.
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?
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.
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.