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
thank you! I will bing(China, you know) it :)
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"
time out, I really don't know why...
This comment is hidden because it contains spoiler information about the solution
but how to resolve "11" and "20000"?
I see, thank you!
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
pretty good!
but I have a question:'zip' object has no attribute 'reverse'.
I tried to add a line'array = list(array)'behind the 5th line, it works.
sorry, I am a freshman in this website
some rules I havn't got clearly now
if I offend the regulation, I will delete the post
Spoilers...
This comment is hidden because it contains spoiler information about the solution
I like this kata, and have solve it.
from this kata, I learned "for...else" structure.
Thanks