프로그래머스 (Swift)/기초
[Day15-4] 길이에 따른 연산
은더기
2024. 4. 12. 08:50
문제
내 정답 코드
import Foundation
func solution(_ num_list:[Int]) -> Int {
return num_list.count >= 11 ? num_list.reduce(0, +) : num_list.reduce(1, *)
}
#
1. 11이 넘으면 모든 값을 더해주고 아니라면 모든 값을 곱해준다.
배운 기술