You need to sign in or sign up before continuing.×
5 kyu
Sports League Table Ranking (with Head-to-head)
15 of 38cshw89
Loading description...
Fundamentals
Algorithms
Arrays
Sorting
Performance
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.
You allow mutation of input to interfere with test cases.
Is it your intention to force performance to the point where I can't write a nice, structured, functional solution with lots of object constructuring and destructuring?
ETA: Node 10 is faster; I get 10/20 through Random Big.
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?
This comment has been hidden.
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.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.
Then there should probably be a
performance
tag.I mostly just have zero interest in solution performance. I aim for correctness and simplicity ( and
find({team}) => team===teamX
was gloriously simple :), and I have compilers to optimise things and hardware to accelerate them. ( Also, if I'm processing300 000
games, I'm willing to wait a little. The waiting won't ever take as long as those games did to play. :P ) Your opinion is of course as good as mine ( and actually better on your kata. :)Ok, I added it.
I agree with Johan on this one. The performance constraints are tedious. Also, when adding performance constraints you should at least have a section in the description describing those constraints.
There are empty items as input in exampleRandomCrazy test
Ups, you are right. They should be 0:0. I fixed it.
I found the description was hard to understand.
Yes, the example is clear, and yes, the text makes sense in hindsight, but the meaning of "Head-to-head" fooled me for a very long time.
I think root of my confusion was you put "Head-to-head" in same bullet list with other comparator criteria
And saying stuff like this made it sound like it was similar to others
Whereas (IMO) the "head-to-head" is different. It's more like "special tie-breaker rules" quite unlike the other comparator criteria.
If it wasn't in that list, and if there was another title (e.g. "Head-to-head tie-breaker rules") I think I would have finished this Kata a few hours sooner!
(Or perhaps I am wrong and just solved this in a clumsy way).
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?
Yes, it is much clearer now. Thanks.
Maybe I'd say tied teams instead of identical teams?