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.
Tell me about it
So that time complexity is O(n) instead of O(n log n) which seems to be what most people have done. IMHO, the test cases weren't rigorous enough to force people to take the more optimal route.
Why?
Passing the first seven test cases. Any hints?
Did you code in Java before? This is almost overkill. It's nice, but it's overkill.
:c
doesn't appear in the first round at all, thus, you may end up not even keeping track of its votes. Thus, you should make sure you count the votes for all candidates even if they don't appear in the first round. Anything not appearing in the first round should be removed, anyway.Interesting. Can you explain what exactly is going on/why this works?
No. Read again the description and see some posts below. It has already been explained:-)
This line:
Test.assert_equals(order_weight("2000 10003 1234000 44444444 9999 11 11 22 123"), "11 11 2000 10003 22 123 1234000 44444444 9999")
Wouldn't the correct response be "11 11 2000 22 10003 123 1234000 44444444 9999"? Because 22 and 10003 have the same digit number, but 22 should come before 10003 like 11 comes before 2000, but it doesn't in the test. I feel like this is contradictory. @g964
Why that? They are not. Lots of guys passed the kata in Ruby.
The test file in Ruby seems to be contracdictory in the second test.
I love ternaries as much as anyone, but using them like that just makes it seem like you're trying to lower your line count. It ends up being a lot going on in 3 lines. Takes away from the simplicity.
The line
n -= 1
is completely unnecessary, as dividing on the next line will return an integer with no remainder.