数値桁数の追加


reduce:
func solution(_ n:Int) -> Int
{
    var answer = 0
    for i in String(n) {
        answer += Int(String(i))!
    }
    return answer
}
func reduce<U>(initial: U, combine: (U, T) -> U) -> U // reduce정의 
func solution(_ n:Int) -> Int
{
    return String(n).reduce(0, { $0 + Int(String($1))!})
}
質問元:https://programmers.co.kr/learn/courses/30/lessons/12931?language=swift
reduce : http://minsone.github.io/mac/ios/swift-map-filter-reduce-and-inference