백준 2577번 숫자의개수

quokka·2022년 1월 8일
0

코딩테스트

목록 보기
50/63

https://www.acmicpc.net/problem/2577

filter를 이용해서 string안의 element값이 0,1,2,3,4,5,6,7,8,9만 가진 String으로 만들어준 후 그것의 개수를 세줬습니다.

import Foundation

if let a = readLine(), let b = readLine(), let c = readLine() {
  let result = String(Int(a)! * Int(b)! * Int(c)!)
  for i in 0...9 {
      print(result.filter{ String($0) == "\(i)"}.count)
  }
}
profile
iOS를 공부하는 개발자입니다~ㅎㅎ

0개의 댓글

관련 채용 정보