We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Exploiting the fact that checking on a range has O(1) complexity when checking integers against integer bounds and using the built-in filter function.
What filter does is basically "let through" only those elements of the iterable (apples) that satisfy the predicate (in this case the lambda function).
The resulting filter object will result in a list that has only the apples fallen on the house, whose lenght is the answer.
Therefore,
Apple and Orange
You are viewing a single comment's thread. Return to all comments →
In a functional way: (using Python3)
Exploiting the fact that checking on a range has O(1) complexity when checking integers against integer bounds and using the built-in filter function. What filter does is basically "let through" only those elements of the iterable (apples) that satisfy the predicate (in this case the lambda function). The resulting filter object will result in a list that has only the apples fallen on the house, whose lenght is the answer. Therefore,