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.
@dmc5809, you could google "python sort key" to get an explanation yourself, you know?
Great solution. I am confused as to how key=weight_key is working. I see you are using the function as a keyword arg, but the function is not being executed (). Can you explain more please?
Thanks
The sorted key parameter receives a tuple from
weight_key
which contains two values: First the weight-value, and second the string value itself.In your example using "11" and "20000" the keys are thus (2, "11"), and (2, "20000"). Hence the weigh-values are equal, but the string values differ and are sorted accordingly.
I hope this clarifies it.
You can find a better range than this: for i in range(2, n+1)
Google is your friend. Try "prime factors algorithm"
This is because my solution is written in Python 2, while you are using Python 3. zip() returns a list in Python 2. In Python 3, it returns ZipObject (a lazy iterator, which computes each next value only when you actually ask for it). See https://docs.python.org/3/library/functions.html#zip
Spoilers...