반응형
Complete the square sum function so that it squares each number passed into it and then sums the results together.
For example, for [1, 2, 2]
it should return 9 because 1^2 + 2^2 + 2^2 = 9.
Solution:
def square_sum(numbers):
square = lambda x:(x**2+x**2)//2
return sum(square(number) for number in numbers)
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
1013. Area or Perimeter (0) | 2022.10.13 |
---|---|
1012. All Star Code Challenge #18 (0) | 2022.10.12 |
1010. Double Char (0) | 2022.10.10 |
1009. Surface Area and Volume of a Box (0) | 2022.10.10 |
1008. Drink about (0) | 2022.10.08 |