5 kyu
Multidimensional Neighbourhood
38sgerodes
Loading description...
Algorithms
Logic
Data Structures
Arrays
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.
This comment has been hidden.
Yes, the Docker version used on CW was updated a year or so ago, and the random generation inside Docker containers became twice as slow. With the current test setup the kata is impossible to complete.
You are right. My solution that had a time score of less than 4 secs get a TLE as well...
Even dividing the number of test by two gives my solution a runtime of 10 secs... What the hell they did to the system that slowed it down to this level?
Ive scaled the tests 6-10 times down. My Solution scores about 4 secs. It should give room for a variety of solutions. Try it out
Kata description:
Typo: "could be a depp list or a deep tuple" <- depp?
N-dimensional and N-length: implying that dimension and length must be the same (N)? matrix a N-dimensional matrix. N >= 0 coordinates of the cell. It is a N-length tuple.
Please clarify the test description. There will be one Tests with a very deep matrix <- one "Test" or more than one "Tests"? There will be 300 Tests with 9 <= distance <= 12 There will be 1000 Tests with N == 4, Dimension size == 5 <- What's "N"? What's "dimension size"? Do you mean 4-dimensional and tuple length of 5? There will be 400 Tests with N == 8, Dimension size == 3 <- What's "N"? What's "dimension size"? Do you mean 8-dimensional and tuple length of 3?
Suggestion: State the same details (e.g. dimension, tuple length, distance) for all four types of random tests.
OK, thanks for your clarification. The issue was that I confused myself by mixing up the tuple length of the centre coordinates and the tuple length of a dimension in the matrix ("dimension size")... Not sure if any rewording is possible.
No, "deep" is not irritating. Just that "depp" is a typo. You may add the word back in the description.
Just caught another typo, please correct it: "apllied".
Thanks again!
In the random tests the elements in your matrix are tuples, not lists.
If both lists and tuples has to be supported it should be mentioned in the description.
The description mentions that the matrix "could be a depp (sic) list or a deep tuple".
As ching ching said - it is. Please read the description carefully.
But the typo hasn't been fixed ;)
The random tests are too big. It's virtually impossible to compare results from them ourselves (for debug purposes, for example).
Can we have small random tests, and then big random tests?
WORK IN PROGRESS. Accidentally published
Is it okay if I use one of your solutions guys to put in in the _reference?
I haven't seen anybody arguing about such things at least ¯\_(ツ)_/¯
If you're going to do that, you should choose B4B's top solution as it's currently the fastest one.
At the same time, you could try using my for testing purposes(!) because it's not as optimized but uses the same idea and should not time out too easily (B4B may disagree with me, but IMO this would be an indication that you're pushing the constraints of a non-performance-oriented kata too hard).
no problem, you can use mine if you want. Note: don't set up a tests suite that takes 11s with that solution though: let some margin for various but still fast implementations. ;)
So, guys, I have composed a solution that is more performant that both yours.) Sory, i will take mine.))) But anyway thanks for the support! B4B scores 4.4-4.5s Mine 3.5-3.8 ^^.
I did it harder, so my old not performant solution is now not surviving and the best by now has about 8 seconds. I think there is enough span to build performant solutions. what do you think?
I think you should make this kata harder.
I've played with your tests replacing your reference with mine and changing the setup to this (quick generation of similar tests, small exec time):
from it I got the following results:
With the following constraints you can use a slow algo and still pass (that's why ZED assesed it as
7 kyu
). Either improve the test suite or simply resolve the issue (and removemathematics
tag as well, as you'd allow solutions which don't use math at all).(Raising as an issue to let the author decide what to do with the kata before somebody suddenly approves it.)
This comment has been hidden.
My solution is okay (I'll still get the points even if it dies :D, and after I made the RNG "fixed" the difference in time was pretty small (run a couple of tests, maybe for some high enough values my solution may become a lot slower than yours, idk)). Moreover, I'm proposing to make the tests harder, not overkill. Ideally, for Von Neumann neighborhood solutions should iterate only over the elements which will be the part of the result, and not the whole N-dimensional cube with the volume of
(distance * 2 + 1)**(dimensions)
- which is what I'd like to see as the requirement.nope, your new solution would still chock to death for what I'm suggesting (you didn't get the idea behind apparently. Unless the solution showing up under your message isn't the good one). But the validity or invalidity of your solution is not the point of my suggestion, here.
EDIT: mmm... Or rather, I didnt' get your message... x) (first part of my answer. The second still applies)
Added performance. Try it out guys. My solution gets 8-9 secs
Mmmmh... that short... ;p
ok, about performances, we have a problem. I timed the different functions of interest during the random tests, using my soluiton as the user's one (butI did it in that fork of your solution, to be sure I use the last version of the test suite):
So, two things: your solution is very slow, the random generation takes a huge part of the time too.
You should change the way you're creating matrices. The tests are TOO random because the same code may pass the tests in 4-6 sec depending on how the matrix is generated (i.e. how many dimensions there're, how long the arrays are).
I also tested my code using B4B's fork:
You are enforcing more optmized solutions now (though still very slightly, as I noted above) but not because tests are intensive, but because your own solution is taking up lots of time. As B4B said, you should either replace your reference altogether or rewrite your solution because instead of using math (again, you have added
mathematics
tag), you're using lots of useless and slow functions which you have written during creating previous katas.@FArekkusu You think I should make the random span smaller?
@Blind4Basics "you have to ensure that the user doesn't mutate the inputs (just double check the first tests, to be sure that you get the same output after the second call." Do you mean I should do the first test twice? like this
The idea of reusing the array is great. Probably I can use tuples instead of lists in the generator to ensure the user does not mutate the input. So the matrix will be a N-deep tuple. I hope it will not affect the times so much.
The idea of reusing the array is great. Probably I can use tuples instead of lists to ensure the user does not mutate the input. So the matrix will be a N-deep tuple.
yes to your
two"three" answers above. ;) And about the first of them:"if you fail this test, might be you're mutating the input. Don't do that."
or something like thatYes, you could break up each set of tests (small, big, huge) into smaller randomized subsets to minimize the difference in generated sizes/dimensions.
Alternatively, a good solution would be to create a few fixed matrices (as tuples of tuples) gradually increasing their size/dimensions count, and then randomize only the central coordinate and distance.
Okay. Close the issue when you think you're done with your changes.
In fact, it should be okay now. Closing.
@FArekkusu; what about the ranking? still 5?
Cmon, i think it is at least 4. Not obvious programming rutine, , Performance. I would give myself a 3 if you ask.:D
I've changed my vote to 4 kyu (still feels kinda 5 kyu to me but whatever).Nah, neither the algorithm required nor its implementation are hard, and this "performance requirement" is only a method to reject inefficient trash solutions (and to not allow this kata to be rated as
6 kyu
at most, which is ZED's vote on a human difficulty scale).4 kyu
would be WAY too generous.hard 5 it is, then.
This comment has been hidden.
hardcoding indexes? MAX_DISTANCE = 5 MAX_DIMENSION = 8 That give us worst case 11^8-1 = 214358880 indexes. I want to see that poor guy doing this and then searching THAT particular index where he fucked up.))
But for the reason of epic shit, I will do it.)
This comment has been hidden.
Added Huge dimensions. Try it out;)
sounds good to me. ;)
Another thing: you should provide the inputs of the
randomedit: SAMPLE tests in a readable fashion. It's already enough mind numbing to deal with the mutlidimensionality, no need to force the user to think about what actually are the data in the input (and honestly, apart from the first one, I have no lcue of what your computing with the formula you use. So just paste the full input arrays... ;p )I just read this message again... 'made sort of a mistake in it, ofc I was thinkgin about the sample tests, not the random ones... x)
" you should provide the inputs of the random tests in a readable fashion" How can i do it? The inputs are massive! or do you mean messages like this "Type: 'moore'; Indexes: (1,2,3); Distance: 3" without the input array.
not the ranodm, I told you, the SAMPLE test! ;) (those visible by the warrior in the trainer. Not all of them, but at least all the 1D and 2D arrays)
changed
damn, that was something, this time... x)
EDIT: btw, you have to tell in the description that negative indexes are considered invalid, here.
I didn't get "completed from first attempt" because none of the previous 3 katas used this vile trick...
@B4B, the kata is still not very hard, IMO. I think
4 kyu
is a bit too much considering how it's not a big step from his previous katas (ZED even assesed it as7 kyu
, lmao).you found it easy, perfect, choose your rank suggestion. I find it harder than you? whatever! (And you perfectly know that ZED ranking is... well, ZED ranking...)
(and I did it while being tired to death so that surely didn't help :p )
EDIT: btw, you still did choose 5 kyu, though... Not so far...
I chose
5 kyu
because it's definitely harder than the previous katas but not much. If it was a standalone kata, I'd probably agree with you, but after doing the 2/3-D versions it doesn't look like a big challenge...I can see why ZED chose
7 kyu
, though. Apart from his passive ability "vote every kata 2 ranks easier than it really is" his code passes the tests despite being terribly slow.@Blin4Basics
"negative indexes are considered invalid"
This should be enough, dont you agree?
not enough specific for python since (-1,-1) is perfectly valid index. That's why I suggested that. But that's my opinion on the subject, ofc.