Date: July 15th, 2017 1:05 AM
Author: Jeff Tezos [1-0 in Proj Euler challenges](socatoa)
In the future you should indent.
1. Good work.
An even better solution would be map(len, names).
No need to write a wrapper function around len, when there is already a built-in len function that does the job itself!
2. A better solution than yours:
numbers = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ]
... return sum(lst)
Your solution would only add arrays of length 3.
Or better yet, just write: map(sum, numbers)
No need to define a sum function when you can just leverage the built-in one!
-- You should use the boolean types True and False, since that is what is required by the result.
-- According to your prime function, 1 and all negative numbers are prime. That might seem like an insignificant mistake, but it would likely come back to haunt you if, for example, you wrote some recursive function that relied on checking results for smaller primes.
--Your solution is extremely inefficient in doing a division in the "while loop" check. Division is hundreds of times more expensive than addition or multiplication for computers. A far more efficient check would be "while x >= 2*y"
--Your solution is a little inefficient in that you can stop once y exceeds sqrt(x) in value.
....y = 2
....if x <= 3:
....while x / y >= 2:
........if x % y == 0:
........y = y + 1