結果

問題 No.289 数字を全て足そう
コンテスト
ユーザー yu0912
提出日時 2020-07-23 17:37:29
言語 JavaScript
(node v25.6.0)
コンパイル:
true
実行:
node _filename_ ONLINE_JUDGE
結果
AC  
実行時間 114 ms / 1,000 ms
コード長 430 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 88 ms
コンパイル使用メモリ 7,972 KB
実行使用メモリ 54,148 KB
最終ジャッジ日時 2026-03-08 21:40:53
合計ジャッジ時間 3,526 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

function main(input = ``) {
  let lines = input.split('\n');

  return Array.from(lines[0]).reduce((sum, c) => {
    if (!isNaN(parseInt(c))) {
      return sum + parseInt(c);
    } else {
      return sum;
    }
  }, 0);
}

const { readFileSync, existsSync } = require('fs');
const stdin = '/dev/stdin';

if (existsSync(stdin)) {
  const input = readFileSync(stdin, 'utf8');
  console.log(main(input));
}

module.exports = main;
0