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.
a nice tap!
It does the trick but there are some really concise solutions here with a fraction of the upvotes...
learnes a big lesson
Nice way to evaluate the arr is not empty or None.
Sorted is O(n log n) complexity, both sorted and sort use the same algorithm behind the scenes. Creating a list is O(1).
The only difference with my solution is math library
coooooool
L comment I won't lie
It can also be None according to the kata description, which would then return None and fail.
intersting!!!
Old comment, but if someone runs into a similar issue - are you returning an array of the values or just the values?
My first attempt returned 10,-65 instead of [10,-65] for the first example problem, which fails.
This comment is hidden because it contains spoiler information about the solution
i did same thing but i just said arr != None its acccepted too here >1
really nice
Since every character in the string has to be touched, assuming 'n' refers to the size of 'aeiouAEIOU' -> 10
String comparison method:
vowel, equal frequencies: 5.5 checks
not a vowel: 10 checks, constant
Set, assuming underlying b-tree has minimal depth:
vowel, equal frequency: 1 * .1 + 2 * .2 + 3 + .4 + 4 * .3 = 2.9 checks
not a vowel: upper bound of 4 checks, lower bound 3 checks
Comparing: vowel 5.5 vs 2.9 -> ~1.90 faster for set
not a vowel: 10 vs 3 to 4 -> 3.33 to 2.5 times faster, in theory
Note: this is in theory, the python interpreter and execution environment could make this worse or better
Obviously as 'n' gets (not much) larger, the set is going to be faster. For n = 10, I would say tradeoff is speed versus speed of coding
Loading more items...