Beta
Sum of primes
Loading description...
Algorithms
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
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 has been hidden.
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.
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.
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?
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.
This comment has been hidden.