結果

問題 No.289 数字を全て足そう
ユーザー t__nabe
提出日時 2020-03-13 17:47:42
言語 Swift
(6.0.3)
結果
AC  
実行時間 19 ms / 1,000 ms
コード長 359 bytes
コンパイル時間 3,932 ms
コンパイル使用メモリ 177,216 KB
実行使用メモリ 17,152 KB
最終ジャッジ日時 2024-11-30 16:54:39
合計ジャッジ時間 3,364 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import Foundation

extension String {
    func extractNumberStrings() -> String {
        let strings = (self.components(separatedBy: NSCharacterSet.decimalDigits.inverted))
        return (strings.joined())
    }
}

let str = readLine()!
var result = 0
for character in str.extractNumberStrings() {
    result += Int(String(character)) ?? 0
}
print(result)

0