[Swift] 자릿수 더하기

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

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