Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Apparently 'groupBy' is supposed to keep the order of the input data. But with 'orderBy' entries with the same key should get a different order? That makes no sense in my opinion. What is the logic that 'scientific' must be before 'teacher'?
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.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.
Ok, I added it.
I check again the performance of my code. The solution runs in only 430ms. The major portion of the runtime is in the setup of the tests (3.5sec). If your code runs in a timeout it means that your code is 20 times slower than the reference solution. In my opinion this is not tolerable.
I am fair enough to reduce the big tests to 15.
But I run some performance tests and I got this results:
my / your (in ms): 42 / 500, 28 / 568, 44 / 832, 45 / 760, 23 / 622
In my opinion the difference is too big. I analysed your code and the problem is
teamX = z.find( ({team}) => team===teamX )
. You search the team in your team array for every single game (~300000 times). I modified your code. Beforegames.reduce
I buffered the teams in an array to accessing the teams by an index. Now I passed all tests with the modified code.This was not my intention. But I didn't optimized my code at all and it runs in 4 seconds. I didn't think the performance could be a problem. Can you post your solution as spoiler?
Your are right. I fixed it.
What do you mean? I don't see any comments in the parts expect of some
# end x
.Ups, you are right. They should be 0:0. I fixed it.
I found it difficult to describe this rule. The term 'tie-breaker rule' is a good point. I copy the term 'Head-to-head' from here https://en.wikipedia.org/wiki/Group_tournament_ranking_system#Tiebreaker_criteria. But i didn't mention 'tie-breaker rule'. I rewrite this part of the description. Is it better to understand?
I created a harder version of this: https://www.codewars.com/kata/5e0e17220d5bc9002dc4e9c4
I added some small examples. Is that better?
You are right. I fixed it.
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.
You are right. Probably I was too focused on this sentence. I thought there is a reason for that. The no-recursive test would be much easier :).
Loading more items...