6 kyu
Most improved - Puzzles #4
76 of 189matt c
Loading description...
Arrays
Puzzles
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.
python new test framework is required. updated in this fork
Description formatting is broken.
Ruby 3.0 should be enabled.
Description formatting is broken.
Once again annoyed by the difference when writing the same thing in different ways..when there are round&random..
If there is a tie in improvements then order by name.
It doesn't mention that it's sort by case first, then letters. (and even in the case of... cases, it doesn't say which case should come up first.) It makes a difference when you have to compare letters of both cases, because there are two ways to sort characters:
editing description to specify it is the first ordering.
Cool Kata!
For the ruby translation: In ruby, hash values are accessed by keys which are either symbols or strings. In the description it tells the warrior to use symbols, where in reality the problem uses strings, so: Example of student Object: {"name" => 'Henry, Johns',"marks"=>[25,50]} instead of Example of student Object: {name:'Henry, Johns',marks:[25,50]} And same with the expected output...Thanks!
It doesn't specify how to specify the key either by string of symbol, they are just examples. This shouldn't make a difference when creating a solution.
For some reason codewars won't run the test on my code. It just draws a blank. Not sure what's going on but it works in the IDE.
I'd have this kata solved in ruby except out of the hundreds of scores one improvement is -57.49999999999999. 13 nines rounds to -57. If my value had 14 nines then it would round to -58, which is the answer for the test case.
I hit submit a few more times and it worked. Whatever.
I will look into this, it does seem like a rare case if you eventually passed it though, thanks for pointing it out!
Looking at the first few test cases, it appears the "overall improvement percentage" is only dependent on the first and last scores. The middle scores are not taken into account. Is that correct? If I were a student in that class, I would not study for the first test, and then skip all the other tests until the final, which I would try to get 100%. Then I would be top of the improvement list!
This list would probably be just for stats, so there would be no point in getting to the top of it.
also in a real life situation you may get most improved but then you'd fail the course, this is just some extra information a teacher may like to know when looking over who has increased their knowledge. :)
everything in this kata is simply wrong.......
sorry, could you explain....?
The description for the ruby translation talks about a 'student class', when in fact, no such class exists. That's quite confusing :(
In Python version, I don't understand where an integer or a floating point number is wanted for the key
improvement
. In basic tests and examples integers are expected while floating point numbers are wanted in random testing??? Quite confusing.I honestly have no clue how python works but.. if you calculated the answer to be a floating point wouldn't you return a floating point number anyway and the same for integers?
resolved :)
I can still see the above mentioned problem by sakana378 in python.
For e.g. consider the following output:
It should work for random inputs too: [{'name': 'don, harold', 'improvement': 127}, {'name': 'blop, cassie', 'improvement': 96}, {'name': 'blop, Johns', 'improvement': 94}, {'name': 'sean, Wish', 'improvement': 0}, {'name': 'whimpy, Bug', 'improvement': 0}, {'name': 'horse, fire', 'improvement': -48}, {'name': 'matt, luck', 'improvement': -66}, {'name': 'mary, zip', 'improvement': -100}] should equal [{'name': 'don, harold', 'improvement': 128.0}, {'name': 'blop, cassie', 'improvement': 96.0}, {'name': 'blop, Johns', 'improvement': 94.0}, {'name': 'sean, Wish', 'improvement': 0}, {'name': 'whimpy, Bug', 'improvement': 0.0}, {'name': 'horse, fire', 'improvement': -48.0}, {'name': 'matt, luck', 'improvement': -66.0}, {'name': 'mary, zip', 'improvement': -100.0}]
In the output we can see that expected result wants improvement to be a float. Please help :(
then i guess use floating point? I didn't write the python solution and i don't know how python works but what i do know is. The python translation had to be submitted with a solution, so one exists also multiple people have completed this kata using python and because not everyones the same there are multiple solutions to the python version. so from that im concluding there was no issue in the first place. I don't know how to help you because i don't know much about python. if someone else here uses python and can provide a hint it would be appreciated.
Well, some random tests expected integer value and some floating point (May be there's something wrong ?). So I didn't change my code at all. I just tried submitting the same code over and over again which helped me finally. Completed the Kata successfully. Thanks!
For the case of
[nil, 100]
the kata seems to be expecting the improvment to be0
rather than infinite. How/why/is this correct behaviour?Are you saying there are cases where the name is nil?
No, when the first mark is 0 and the last mark is 100.
IIRC, the kata expects it to be a 0 improvement because you actually only scored for a test, so no improvement.
I know at least it's defined in the javascript description (I believe they should be the same) if a score was nil or null treat that as a 0, nil/null just means that test was not sat so the score does not apply to the student. :)
It would be nice if the test cases could provide better information about where in the array the errors were.
How specific did you want?
Something like:
That gives a quick summary, but also provides the full output to check.
Ruby: Random tests are not sorting correctly by student name.
"ash, cow" should be before "steve, plum"
Mh, you are right, but I modified the solution slightly and now I can't reproduce this error any more, while the basic test cases with more students with the same improvement work just fine; can you confirm if you happen to have this problem any longer?
[Also, posting directly under my comment below would help me get faster notifications^^']
Also, sorry to bother could you also look at your translations on this kata when you have the time, thanks :)
Still broken. "john, Johns" < "leroy, white"
Changed the sorting code as I saw in some remote chance it could give problems: can you please confirm me it now it works well enough :)?
Since no reply assuming sorting code has been fixed marking as resolved :)
Confirm fixed.
Upvoted, translated :)
[Sooner or later I will also find the mental strength to do the same with the messy bug fix #10 ;)]
Thank's for your most beautiful translations yet again! yeah that might be a tough one to write for other languages cause there is a fair bit of code :)
Ruby tests still broken.
There is an issue with sorting in the random tests. From expected results:
{"name":"leroy, plum","improvement":0},{"name":"blop, King","improvement":0},{"name":"frog, cow","improvement":0},{"name":"jeff, willow","improvement":0}
{"name":"god, cow","improvement":-100},{"name":"freeman, Act","improvement":-100},{"name":"whimpy, brown","improvement":-100}
I don't see what's wrong straight away, Could you explain what's wrong here? If you could please post your solution and mark it as having spoiler content :)
In the description, it says
If there is a tie in improvements then order by name.
In the above examples, where there is a tie, my solution puts the names in order by the first letter of the name field (or more letters as necessary). For instance, in the first example, where all of the improvements are0
,{"name":"leroy, plum","improvement":0}
should be last if we sort by that method, because the first letter of the name (l
) comes after the first letter of all the other names alphabetically. Hypothetically, we could be sorting by the second name, but in that caseleroy, plum
would be second to last, andfrog, cow
would be first. Same goes for the improvements of-100
, I would think thatfreeman, Act
should precedegod, cow
.Sorry I see now I'll go and fix it up thank you for raising an issue :)
if you could test it now thank you :)
All better.