5 kyu
Sports League Table Ranking
109 of 582cshw89
Loading description...
Fundamentals
Algorithms
Arrays
Sorting
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.
CS: I think the labeling in the error message is reversed for the following tests: RandomBig, RandomFull, RandomTestsAlmostEmpty, and RandomTestsManyShare
Example: RandomTestsAlmostEmpty
Test Failed Expected: null
But was: < 66, 16, 4, 55, 76, 55, 36, 5, 34, 1, 35, 57, 60, 86, 6, 12, 16, 66, 60, 26, 19, 84, 40, 66, 26, 43, 26, 60, 26, 66, 43, 23, 77, 26, 50, 23, 66, 60, 74, 88, 43, 23, 12, 38, 6, 60, 85, 43, 57, 60, 6, 38, 21, 32, 20, 50, 74, 50, 50, 16, 40, 6, 2, 79, 43, 6, 66, 83, 77, 79, 12, 66, 2, 66, 32, 43, 40, 50, 26, 79, 86, 57, 6, 21, 79, 12, 43, 36 >
These sorting algorthims are always so sophisticated to program.
C# Translation
approved by someone
This comment has been hidden.
Nice kata:)
When I Test my Code locally, it passes all Tests, but when i test it on Browser it just fails at test example3. I cant see any way how to debug the test and I cant understand any of the logs. Could you please correct this issue?
This comment has been hidden.
You have to return a list.
Some of these tests are a little excessive. I am passing all the sample tests, but can't pass the final tests and can't compare because they're all too long to read and just say, "and x others"
same. realistically a league wouldn't contain such large amount of teams
This comment has been hidden.
search about "key sorting functions"
thanks man,I finally managed to pull it off!!
I found an interesting thing - my sorting function is working perfectly in browser, but the result differs in codewars, that's why I can't solve the kata. And this this is not a first time when results differ. Would be very thankful for any advices or explanation.
My code has passed all of the sample tests but it is failing for the bigger ones. Could you please provide me any suggestions on what to look for? what kinda situations may not be present on the tests cases that are being tested on the bigger cases? By any chance, would you have any big test case that you could share with us? Thank you!
What the error message of the failed test? Btw, when 'big' tests are failing, I try to debug the code with console.log() for example. I hope this can help you to investigate the issue in your code.
You cant debug with console.log() because of large size of data. I can't see neither input data (games), it looks like "... 422534 more items ]", nor output "expected [ Array(978) ] to deeply equal [ Array(978) ]". Any thoughts how to solve this if you even don't know where the problem is hidden? As it was said above, all smaller tests are passed successfully.
Do you get a timeout? Then you may need to optimize your code. Otherwise I tried to debug my code by printing the table with
Rank, Team, For, Against, GD, Points
like in the description. Maybe this could be helpful.Thank you all for taking the time to answer my question. @ytorn is correct, I can't use console.log() because of large size data. Just to clarify, I'm not receiving a timeout, the tests complete on time but the array Im returning is not equal to the expected one. I tried to login games, Rank, Team, For, etc but the only thing Im receiving is "expected [ Array(#) ] to deeply equal [ Array(#) ]". That's why I was wondering if maybe some good sould have a large dataset to test my code :)
@jsalinasf, I have faced exactly the same thing, and this is the main question - how to fixed something that is not visible. No errors, no timeout, nothing. Just half of tests is correct, another half is not and you can't discover what's wrong
@ytorn I agree with you. From where I'm standing, there are only 3 few possible options:
Why would team rankings for six teams given in the example come out as [4, 4, 6, 3, 1, 2] if --as the input data shows-- all teams have played a game? Teams 0 and 5 deserve to be in there!
And there was no instruction how to handle instances where a team did not play.
Perhaps as a guy always chosen last in gym class I am missing something here.
The output should be an array of ranks for each team, not an array of teams for each rank. So the array
[4, 4, 6, 3, 1, 2]
means that the rank of Team 0 is 4, the rank of Team 1 is also 4, ..., the rank of Team 5 is 2. A team, which has not played yet, got 0 points, 0 goals scored and 0 goals conceded. But with these stats the team can still be ranked.Thanks for clarification!
ruby:
Fixed it.
the python version is a total mess... x/
example_random_single
Your are right. I fixed it.
What do you mean? I don't see any comments in the parts expect of some
# end x
.mmh, right, I took that for commenting out ruby code except... that's not ruby code, that's just your coding habits, I guess... Ok, resolving. Tho, you still should remove those, since it's pretty unusual in python code (at the very least, remove them from the sample tests and the solution setup)
assertArrayEquals(new int[]{2,3,4,1,5,6}, LeagueOrder.computeRanks(6, new int[][] {{0, 5, 2, 0}, {1, 4, 2, 2}, {2, 3, 1, 3}, {1, 5, 0, 0}, {2, 0, 2, 1}, {3, 4, 3, 1}})); I think the teams rank 5 and rank 6 have same rank 5 cuz both of them are: GD:-2 && P: 1
The answer is correct.
Yes, Team 4 and Team 5 have same GD=-2 amd P=1.
No, they are not equal ranked because Team 4 scored 3 goals and Team 5 scored 0 goals.
I created a harder version of this: https://www.codewars.com/kata/5e0e17220d5bc9002dc4e9c4
Ruby translation
hi,
plz see the issue I raised above about your translation.
cheers
Approved by 🧙
From description:
Um, I think you mean Team 5 and Team 3
You are right. I fixed it.
It seems that reference solution additionally tiebreaks by number of games played or something?
Team 11 reaches 2 points because of the win. The teams 5, 6 and 10 got only 1 point (1 draw). Hence team 11 have to be ranked at the 5th place alone.
Okay, I saw the problem in my code now.
Are there smaller tests? The tests are all very big and it's very hard to see what's happening when something is not expected.
I added some small examples. Is that better?
Definitely ;-)