์ˆซ์ž๋งŒ ์ถ”์ถœ

2022. 10. 7. 23:07ใ†Algorithm

์ˆซ์ž๋งŒ ์ถ”์ถœ

 

 

 ๋ฌธ์ œ ์„ค๋ช…

 

 ๋‚˜์˜ ํ’€์ด

 

๋ฌธ์ž์—ด์— isNumberํ”„๋กœํผํ‹ฐ๊ฐ€ ์žˆ๋Š” ์ค„ ์•Œ๊ณ  ์‚ฌ์šฉํ•˜๋ คํ–ˆ๋Š”๋ฐ ์•Œ๊ณ ๋ณด๋‹ˆ Characterํƒ€์ž…์— ์กด์žฌํ•˜๋Š” ํ”„๋กœํผํ‹ฐ์˜€๋‹ค.

๊ทธ๋ž˜์„œ ๋ฌธ์ž์—ด์ด Intํ˜•์œผ๋กœ ๋ณ€ํ™˜๋˜๋ฉด ๋ˆ„์ ํ•˜๊ณ  ์•„๋‹ˆ๋ฉด continueํ•˜๋Š” ์‹์œผ๋กœ ๋ฌธ์ œ๋ฅผ ํ’€์—ˆ๋‹ค.

 

func getNums(_ arr: [String]) -> Int {
  var result = ""
  for x in arr {
    if let num = Int(x) {
      result += String(num)
    }
  }
  let val = Int(result)!
  print(val)
  return (1...val).filter{ val % $0 == 0}.count
}


let input = Array(readLine()!).map{String($0)}
print(getNums(input))