16
perimeter
1 14 31
1216/ 1445
Last seen 1 month ago
Member for 2 years, 7 months, 4 days
Difficulty Normal
Best reviews / Newest reviews
made easier using insert-Stensen 1
Kudos for using enumerate() to obtain indices of zeros (if any present). I used index() method but it is too cumbersome, one has to track the start index to get next zero occurrence with index(), which is too error prone. More
I like to map it, map it-veky 1
Great! A great example of map's use with more than one iterable. More
1-liner: itertools.compress-Stensen 1
What happens when the very first element in items (here aliased to l) is by chance equal to 0? [itertools.compress](https://docs.python.org/3.8/library/itertools.html#itertools.compress) _Make an iterator that filters elements from data returning only those that have **a corresponding element in s More
First-lexxPR 1 1
type of expression "len(password) > 6" is already boolean, no need to extend it with a conditional, the expression itself should be returned. Anyhow it would work, but it consumes slightly more processing power. More
lambda and reduce-sanello
Great use of functools.reduce() to solve the problem, my solution is very similar. No need to use a lambda function here, operator module provides mul(tiply) function. Sure then another import line is needed, but I think the less code is written the smaller probability is to introduce bugs. More
Naive solution-alba51
What happens to the very first element and its position enumerate yields? Definition of enumerate: enumerate(iterable, start=0) then the if becomes: if e != elements[-1]: So effectively it compares the first element's value to that of the last one. But this does not pose a problem if all eleme More
First-Oleg_Domokeev
My solution matches yours. How about that? More
First-Tan_Hoe_Jack
min() was effectively used for list sorting. However Python already has dedicated methods and functions to sort: sort() method of lists which does it in place (it changes, mutates the list) and sorted() builtin function which can be used on any iterable, and does not change its input. While buildi More
First-defensor
It should work. However you could use zip(*iterables) built-in function to produce "a stream of pairs from a pair of streams" to quote Ned Batchelder from [Loop like a native: while, for, iterators, generators](https://www.youtube.com/watch?v=EnSu9hHGq5o). More
First-liuq901
Instead of using range() and indices to access elements you can off load that error prone activity to zip(*iterables) built-in function which produces "a stream of pairs from a pair of streams". Also slicing could be used to select odd and even elements of the input. More