6 kyu
Biggest of the Smallest of the Biggest of the...
Loading description...
Algorithms
Arrays
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.
The prioritized thing is not clearly defined. Actually, the array has be sorted differently, depending on the type
smallest
(by values then by largest indexes prioritized) orbiggest
(by values then by smallest indexes prioritized)This comment has been hidden.
Except it is NOT. Examples are not specifications. What you give there are examples. I don't wanna have to read your mind when I see random tests failing while the rules aren't explained properly (edit: btw, this means you don't have enough fixed tests anyway).
For instance, I'm still waiting for an explanation of the input I gave below. According to what MAY be deduced from your non specifications, I don't see how the expected output could be right. So you need to give actual specifications.
note: I don't see the content of the issue below so, sorry if it's about the same thing.
Cheers
No, it's about the reference solution being wrong.
This would explain my problem with the random tests... (but that doesn't change the fact that the problem needs actual specifications)
I don't really know how else to explain it except by using examples. This is sort of an abstract problem that you wouldn't come across in the real world, and jumping right into an explanation of how to solve it just didn't feel right.
Feel free to edit the description if you have one that would work better.
Thanks!
Nope, that's your kata. But basically, what you're trying to ask for is:
And in addition to that, you have the extra infos about the inputs, the fact that one has to cut in half at each step, the odd length situation, ... Up to you to build something meaningful with that.
Cheers
Ok, the description has been reworked again. I hope it explains it better this time.
this part still isn't explained when needed (ie. near the start of the description, not "way later inside a note" or something equivalent ;) )
The part I'm confused about is... how many "biggest" values are you meant to be getting? Could someone explain how that works to me?
Reference solution is still wrong. The most blatant random test I am failing is
Since we have to work from the back of the string:
[5512, 2]
[2]
So where does the expected
[0]
come from? It gets filtered out in the first iteration.This comment has been hidden.
Ok, thanks for the help.
Fixed the reference solution yet again...
still not good, I believe:
I'm just gonna use your solution for the reference. Can't get mine to work...
Seems correct now. My solution produces the same results.
looks like so
yes, finally, I'm passing.
Hi,
The description is especially unclear about what actually means "biggest/smallest" here, and about how the data should be put in the resulting array. Currently, the task is to read the mind of the author, which is never a good sign.
description:
the biggest of [2,9,8,5,6,3,4,7,1] is [9,8,5,6,7], the smallest of that is [5,6], and the biggest of that is [6].
->[9]
, not[6]
random tests:
you still have some logs that shouldn't be there, apparently (see below: 2 logs in the same
it
blockI don't get why the below is wrong:
arr:
4702,5,78,21,80,3, 4, 4683,8,1,6, 7251,8,7, 6490,4, 3228, 8460,5,5,133, 8
small:
5,3,4,8,1,6,8,7,4,5,5
(last 8 isn't there, is it?)big:
5,8,6,8,7,5
big:
8,8,7
=> ??
cheers
What the "biggest/smallest" of an array means is described in the intro of the description, so make sure to read through the whole thing. The example does not go through the whole process of obtaining the desired array.
As for the logs, I had fixed this issue before but forgot to save it :P, the example solution was a recursive function, but instead of calling itself, it called the users function, which is where the extra logs came from. I just got rid of the recursive function altogether and used a loop.
For the example that didn't make sense, I figured it was something in my function again, so I rewrote it and made sure it worked.
Thanks for the feedback!
I don't see how this answers the question. The order in the result set remains a mystery to me.
"biggest" takes the
ceil(50%*length)
biggest values of the array, "smallest" thefloor(50%*length)
smallest values. If some values are tied because there are multiple occurences of the splitting 'pivot element' only the left most occurrences of them are taken into the resulting array until the desired length is reached. Overall the input order has to be maintained and only values have to be filtered out in the process.This I did, but I kept failing some random tests. The current draft version of the kata seems to be correct.
The description only mentions that arrays with length
1
should be preserved at the start, but the random tests expect that this also stays the same during all the operations. aka this test is needed:Ok, I fixed the description to make that more clear.
Reference solution is calling the user function.
Yeah, I see that now. Fixed it again.
This comment has been hidden.
Random tests are vulnerable to input modification. You should compute the expected value first, before calling
assert
(which runs user function first)Ok I fixed that.
Looks like changes have been made, but the status of this kata is that it's still in draft. Are you ready to publish again? I have a working solution per your changes.
Yep it's published again.
We must live in different timezones because I missed it again :D
Well it's published right now so do it fast before more issues arise... :D
Why doesn't it become
[]
after "the smallest"?Sorry about that, I should have made that case more clear.
I've updated the description now to be:
From random tests:
How is a
6
expected to come before234
?That was a mistake in the code on my part.
It's fixed now.
Your random testing is problematic. I cannot see any console logs being grouped with a particular test, they're all lumped in together.
The random test cases are initialized all together, and then the tests are run on the results.
I couldn't find another way to have random tests, but still have a descriptive test name (e.g.
Random Test (the biggest of the smallest of [234,67,231,56,8,9]
If it's really problematic I could just get rid of the descriptive test names and have each test initalize when it runs.
Most katas have no problems with this. All you need to do is put each test under
@test.it
block, IIRC.Why do you need to initialize all tests at once? One at a time could work too :P
Try to see test cases of other katas to see how this could be resolved, or ask about it on CW Discord.
Uh... Yeah... I don't know why I was doing it that way... Fixed it now...