iOS 개발 공부

[Swift] 자릿수 더하기 본문

프로그래머스/Lv.1

[Swift] 자릿수 더하기

물복딱복준복 2023. 2. 15. 14:18
import Foundation

func solution(_ n:Int) -> Int
{
    return "\(n)".compactMap { $0.hexDigitValue }.reduce(0, +)    
}