結果

問題 No.289 数字を全て足そう
ユーザー gemmarogemmaro
提出日時 2020-03-30 21:08:36
言語 Elixir
(1.16.2)
結果
AC  
実行時間 650 ms / 1,000 ms
コード長 354 bytes
コンパイル時間 1,071 ms
コンパイル使用メモリ 55,088 KB
実行使用メモリ 51,372 KB
最終ジャッジ日時 2023-08-29 23:52:47
合計ジャッジ時間 18,055 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 622 ms
50,040 KB
testcase_01 AC 626 ms
50,056 KB
testcase_02 AC 631 ms
49,056 KB
testcase_03 AC 630 ms
50,104 KB
testcase_04 AC 632 ms
49,464 KB
testcase_05 AC 650 ms
49,408 KB
testcase_06 AC 633 ms
50,676 KB
testcase_07 AC 642 ms
49,856 KB
testcase_08 AC 634 ms
50,584 KB
testcase_09 AC 627 ms
49,168 KB
testcase_10 AC 627 ms
49,344 KB
testcase_11 AC 635 ms
49,932 KB
testcase_12 AC 630 ms
49,872 KB
testcase_13 AC 635 ms
50,544 KB
testcase_14 AC 639 ms
50,080 KB
testcase_15 AC 623 ms
50,500 KB
testcase_16 AC 621 ms
49,392 KB
testcase_17 AC 626 ms
49,924 KB
testcase_18 AC 633 ms
50,612 KB
testcase_19 AC 628 ms
50,648 KB
testcase_20 AC 633 ms
50,576 KB
testcase_21 AC 632 ms
49,156 KB
testcase_22 AC 638 ms
49,952 KB
testcase_23 AC 641 ms
51,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

defmodule Main do
  def main do
    IO.gets("")
    |> String.trim()
    |> solve
    |> IO.puts()
  end

  defp solve(s) do
    s
    |> String.to_charlist()
    |> Enum.map(fn x ->
      [x]
      |> to_string
      |> (&(case Integer.parse(&1) do
              {n, _} -> n
              _ -> 0
            end)).()
    end)
    |> Enum.sum()
  end
end
0