結果

問題 No.289 数字を全て足そう
ユーザー t__nabe
提出日時 2020-03-13 17:49:04
言語 Swift
(6.0.3)
結果
AC  
実行時間 19 ms / 1,000 ms
コード長 344 bytes
コンパイル時間 1,533 ms
コンパイル使用メモリ 178,024 KB
実行使用メモリ 17,024 KB
最終ジャッジ日時 2024-11-30 16:55:20
合計ジャッジ時間 2,805 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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
_ = str.extractNumberStrings().map {
    result += Int(String($0)) ?? 0
}

print(result)

0