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.
Thanks a lot for the explanation!
It indeed can be close to linear for this particular form of data present in this kata, which is already almost sorted.
Do you have some link about that? Here it says it is on average O(n log2 n)
How is sorting linear? Any reference on this?
This is linear time. Check out how Python's sorting algorithm works.
Some 1-liners are difficult to figure out what it's doing. This one is pretty easy to read.
This comment is hidden because it contains spoiler information about the solution
I also chose sorting, but I'd like to run some time comparisons on these different methods.
I'm pretty sure that memory swaps cost more time than comparisons.
I did sorting just like you. I need to learn when you can make an if else be on a single line.
I would like to compare the run speeds of this versus some of the other methods. Sorting should
be fast with most of them the same, no swaps should need to happen.
This has to do with floating point rounding errors. The formula can be rearranged a little bit so that the rounding errors have less impact, I believe.
If you have 1 red marbles and 99 green marbles in a box that is your 99 percent.
Now think about having the same 1 red marble and a quantity of green marbles such that
there are 98 percent green and 2 percent red. See if you can work out a formula for that.
Are you saying that the tests fail? What do you mean result 0?
I was having issues with most of them passing, and some failing.
Then I remembered about how computers store floating point and you can get
little rounding errors. Look at your formula and see if you can simplify it some.
Nice. I feel like I learn more by trying a certain way, then reading how others do it, and I'm like "wow cool!"
This comment is hidden because it contains spoiler information about the solution
I think the first one I picked (count the vowels) was more difficult than this one. I'm not sure what level that one was. Of course, after I solved it, I saw several clever 1-Liners.