Thanks! π
Yeah, reduce itself doesnβt mutate the array, but since I used arr.pop() inside it, the array gets mutated during the process.
You're totally right β wrapping arr as [...arr] before sorting and reducing would make it safer and more idiomatic.
I based this translation off of the C one, and I thought that this would be the better choice. Thinking back, long long would have probably been a better idea.
Due to the range being half negative and half positive numbers, about half of the tests could be passed by just returning 0. Though, thinking back, I think it would have been a better idea to generate 200 test cases: 100 with positive numbers and 100 with negative ones (and shuffle them beforehand).
Oh, you're correct, it is exploitable indeed. When writing large test cases, it looks like I just copy-pasted the small test parts and forgot to modify them. I just assumed something about myself that I didn't do. It's not my code to begin with; I just did some cleaning π
I think it should be good now. Please review it again.
Made this fork in JS.
Below is a representation of the average number of duplicates on 7 runs (700 tests). The indexes (0-99) are the number of duplicates for the test and the values are the number of time this number of duplicates was the solution.
From what I can tell, none of the translations use fixed-length arrays or tuples, and none of the reference solutions make any assumptions of outer/inner array length. The phrasing in the description may be brief, but it is sufficiently language-agnostic and it is very clear what is being asked for.
Regarding the test inputs all being 3x3, why not? The kata description makes no statements regarding input size other than the single example earthquake which is 3x3. Also, if a particular language's tests show the input upon failure (which they really should for a 7 kyu), having a smaller array will make it easier to debug your failing solution.
I think it looks reasonable, but I know nothing about C#, I don't feel confident to approve it myself, and this kata is peculiar and particular in its testing.
OK thanks, saw that you authored a lot of katas...
Moves the ref solution to the private section (learnt a thing there), also implemented the other ideas.
Note: I'm not confortable (at all) with range v3 and fmt/... with C++17 clang (therefore pretty comfortable with c++20/23 stuff ) but with clang there is a hell of a lot of shi.. to include...
You #4 is indeed nice !
approved
Ok, done.
Done.
Thanks! π
Yeah, reduce itself doesnβt mutate the array, but since I used arr.pop() inside it, the array gets mutated during the process.
You're totally right β wrapping arr as [...arr] before sorting and reducing would make it safer and more idiomatic.
Appreciate the kind words!
Done.
Done.
long long
would have probably been a better idea.Will do both in a moment.
Approved (though can't mark the suggestion as resolved)
Approved.
When writing large test cases, it looks like I just copy-pasted the small test parts and forgot to modify them.I just assumed something about myself that I didn't do. It's not my code to begin with; I just did some cleaning πI think it should be good now. Please review it again.
Edit: Got approved.
Made this fork in JS.
Below is a representation of the average number of duplicates on 7 runs (700 tests). The indexes (0-99) are the number of duplicates for the test and the values are the number of time this number of duplicates was the solution.
Let me know what I could improve !
From what I can tell, none of the translations use fixed-length arrays or tuples, and none of the reference solutions make any assumptions of outer/inner array length. The phrasing in the description may be brief, but it is sufficiently language-agnostic and it is very clear what is being asked for.
Regarding the test inputs all being 3x3, why not? The kata description makes no statements regarding input size other than the single example earthquake which is 3x3. Also, if a particular language's tests show the input upon failure (which they really should for a 7 kyu), having a smaller array will make it easier to debug your failing solution.
Would you please review this fork?
I think it looks reasonable, but I know nothing about C#, I don't feel confident to approve it myself, and this kata is peculiar and particular in its testing.
OK thanks, saw that you authored a lot of katas...
Moves the ref solution to the private section (learnt a thing there), also implemented the other ideas.
Note: I'm not confortable (at all) with range v3 and fmt/... with C++17 clang (therefore pretty comfortable with c++20/23 stuff ) but with clang there is a hell of a lot of shi.. to include...
You #4 is indeed nice !
Loading more items...