Skip to content

Instantly share code, notes, and snippets.

@hauleth
Created December 2, 2017 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hauleth/7a7a7752c17f50cb2c0b2eeb1e0841c8 to your computer and use it in GitHub Desktop.
Save hauleth/7a7a7752c17f50cb2c0b2eeb1e0841c8 to your computer and use it in GitHub Desktop.
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