Beta
Pharaoh's pyramid of sum
10Rei_00
Loading description...
Mathematics
Performance
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.
As mentioned in an earlier comment, you should explain the concept a bit better. At least the job of a
forerunner
must be explained.In random test,
p
is not always a prime number.Oops... hope I fixed that
The tests should run the ref sol first or copy the array first before executing user solution.
What I meant is not flip the ref sol result with user sol in the assertion, because that will give
Expected <ref sol> to equal <user sol>
on error. That will be confusing for users of course.Run the ref sol first and put the ref sol result into a variable. And then, run the user sol and match it with the ref sol result variable.
Thanks! Me like klutz)
Fixed it
Actual tests only go up to
2500000
. Since any solution must be at least linear it's just impossible to not time out with this constraint.(If you're reducing this constraint, you should turn
f
into an actual array too: an array of2500000
elements is certainly possible)Besides, the time taken for the tests are too volatile: even the author solution sometimes time out.
Thanks a lot for the comments!
Now the answer is searched modulo a prime number.
So I can remove restriction for
k < 30
and sift out the naive solution without volatile test.And now the implementation of the module is an significant part of this kata
My linear solution times out. What is the expected time complexity?
FYI, my O(nlogp) solution passes in 6 to 9 seconds.
Multiplication and division of large integers is not O(1) so your solution is not really linear. :)
Tests should not use
assert_approx_equals
: it is reserved for comparing floating point numbers where calculations are not exact.In this case the answer is exact, only the tests choose to use floating point numbers for some reasons.
Fixed it
I think this needs much clearer instructions.