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.
first and second points: see my fork.
third: yep, I messed up my reasonning (was thinking about
apples
, I guess). Note that this remove thing is still O(n), even if you shrink theapples
list on the way. Tho, using remove, you iterate a second time on the beginning ofapples
, while you already did that with the generator. So still a bad idea (Surely that's what I was thinking about, 2 years ago...).And note too that
pop(0)
is the worst thing you could do about performances.see the fork to come.
elif...:continue
Reverse which conditions? Each branch handles a different case, the middle elif block handles the double rotten case. Replacing continue with pass would be equivalent, but the block is required and I'm not sure where you're suggesting I move it to.next(iterator[, default])
, good to knowpacked
in the else clause is appending. Theapples
variable is iterated through, but only forward from the current position until a complementary box is found which avoids looking backward in thepacked
list or looking through the whole remainingapples
list.Not enforced.
elif...: continue
isn't useful, reverse the conditions to skip that partpacked
list each time you reach the else statement, that's not a good idea