結果

問題 No.289 数字を全て足そう
ユーザー yu0912yu0912
提出日時 2020-07-23 17:37:29
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 359 ms / 1,000 ms
コード長 430 bytes
コンパイル時間 26 ms
コンパイル使用メモリ 5,216 KB
実行使用メモリ 44,584 KB
最終ジャッジ日時 2023-09-05 22:27:16
合計ジャッジ時間 3,498 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
42,180 KB
testcase_01 AC 79 ms
42,216 KB
testcase_02 AC 80 ms
42,260 KB
testcase_03 AC 78 ms
42,180 KB
testcase_04 AC 78 ms
42,128 KB
testcase_05 AC 81 ms
42,064 KB
testcase_06 AC 79 ms
42,260 KB
testcase_07 AC 82 ms
42,308 KB
testcase_08 AC 83 ms
42,236 KB
testcase_09 AC 79 ms
42,136 KB
testcase_10 AC 79 ms
42,084 KB
testcase_11 AC 81 ms
42,428 KB
testcase_12 AC 82 ms
42,360 KB
testcase_13 AC 79 ms
42,220 KB
testcase_14 AC 81 ms
42,428 KB
testcase_15 AC 81 ms
42,680 KB
testcase_16 AC 80 ms
42,200 KB
testcase_17 AC 80 ms
42,220 KB
testcase_18 AC 80 ms
42,436 KB
testcase_19 AC 81 ms
42,376 KB
testcase_20 AC 80 ms
42,388 KB
testcase_21 AC 78 ms
42,288 KB
testcase_22 AC 81 ms
42,304 KB
testcase_23 AC 359 ms
44,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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