Created
December 2, 2017 16:56
-
-
Save hauleth/7a7a7752c17f50cb2c0b2eeb1e0841c8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Advent1 do | |
def sum([h|_]=list),do: do_sum(list++[h],0) | |
defp do_sum([_],sum),do: sum | |
defp do_sum([a|[a|_]=rest],sum),do: do_sum(rest,sum+a-?0) | |
defp do_sum([_|rest],sum),do: do_sum(rest,sum) | |
end | |
IO.puts Advent1.sum to_charlist IO.read :all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment