๊ธ€ ์ž‘์„ฑ์ž: ์ด์ง€์›๐ŸŒฉ๏ธ

๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ๋“ค์–ด์˜จ x๋ฅผ ๋ฌธ์ž์—ด๋กœ ๋ณ€ํ™˜ํ•œ ๋’ค, map์œผ๋กœ ๋‹ค์‹œ Int ํ˜•๋ณ€ํ™˜ํ•ด์„œ ๊ฐ๊ฐ ๋‹ค ๋”ํ•œ ํ›„ ๋‚˜๋จธ์ง€๊ฐ€ ์žˆ๋Š”์ง€ ์—†๋Š”์ง€ ์—ฌ๋ถ€์˜ ๋”ฐ๋ผ ๋ฐ˜ํ™˜๊ฐ’์„ ๋‹ฌ๋ฆฌ ํ•˜๋ฉด ๋œ๋‹ค.


๋ฌธ์ œ

https://programmers.co.kr/learn/courses/30/lessons/12947


๋‚ด๊ฐ€ ์ž‘์„ฑํ•œ ์ฝ”๋“œ

Swift

func solution(_ x:Int) -> Bool {
	let h = String(x).map { Int(String($0))! }.reduce(0, +)
    return x % h == 0 ? true : false 
}
๋ฐ˜์‘ํ˜•