6 kyu
Squared Spiral #1
83 of 105lfhohmann
Loading description...
Geometry
Performance
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 comment has been hidden.
I understand your point, but this Kata is looking for the fastest possible solution, all other solutions are meant to Time Out.
Approved.
reopening: if you checked that the O(log n) verison cannot pass the current version, you can close this one. but considering this solution is passing, I'm tempted to say that the perf tests aren't hard enough
I believe I finally managed to fix it. Tested your provided solution and it no longer passes.
very bad idea: doing so you're changing drastically the perf requirements. The idea was to silence the tests, and do more of them (because without all the assertions to print to the console, the code will execute faster).
You're supposed to use something like this:
the last line is about your last question. If you silence the tests that way and all results are correct, you need it so that at least one (succesful) assertion is done in the
test.it
block.Note: if you're not sure about what you're doing, don't resolve the issue and wait for feedback. That avoids the need for raising another one.
edit: btw, you should have in your test suite a version in O(log n) of the solution, so that it's possible test it quickly, to tune the number of tests and the input range, making sure it cannot pass the tests. Maybe you already have that, I don't know: I cannot see the test suite, for now.
Ok, I see what you mean now, I'm gonna change the random tests suite to match your code.
very bad idea: doing so you're changing drastically the perf requirements.
What do you think, the random tests parameters should be? Keep it at 10,000 now that thes tests were silenced or change it to another value?As you can see, I'm no expert programmer, but I believe the current test suite solution is already O(1).
yes it is O(1). To correctly setup the performances tests, you should use a O(log n) implementation, to make sure it doesn't pass the required number of tests (then you switch back to the O(1) one to update the kata)
I'm believe I'm missing the point, shouldn't the fastest implementation be prefered for the test suite, aren't we trying to measure the users code performance? And what is the advantage of going O(log n)?
The point is not to switch to O(log n), but to use a O(log n) solution to fine-tune your tests, to make sure that the O(log n) solution always fails, while the O(1) always passes.
the random tests must be silenced if succesful: 10000 assertions are just killing the browser (note: don't forget to add one passing assertion at the end of the loop^, when all answers are good, and break the loop at first wrong answer). Once done, the perf requirements must be verified again, because the amount of data to currently transfer (assertions) is very time consumming, so maybe the setup won't be appropriate anymore
and fixed tests with small values should be present too in the full test suite
And what do you mean exactly by "add one passing assertion at the end of the loop^, when all answers are good"?
Thanks for the input
Great fun Kata !
Wrong function name in Solution Setup :
square_spiral
shoud besquared_spiral
.Thanks for the heads up! Fixed the function name, changed to
squared_spiral
Reference solution should use an O(1) algorithm.
I was wondering if the range of tests should be raised to enforce a O(1) solution?
My idea was to create 2 different katas, this one for begginers and this other one, which enforces speed and performance
The problem is that finding a O(1) algorithm for this one is only slightly harder (if at all) than anything slower. I don't think there is enough of a difficulty gap to make the O(1) version worth a seperate kata.
I'll unpublish the other one and keep only this one, I'll also enforce the performance and speed through more tests and larger numbers.
describe
/it
blockshttps://docs.codewars.com/authoring/guidelines/submission-tests/
https://docs.codewars.com/languages/python/codewars-test
describe
/it
blocksI believe everything should be right now. Thanks for the input.