Skip to content

Instantly share code, notes, and snippets.

View cmg-dev's full-sized avatar

Christoph Gnip cmg-dev

View GitHub Profile
# http://adventofcode.com/2017/day/1
defmodule Day1 do
def sum1(digits), do:
digits
|> Stream.concat(Enum.take(digits, 1))
|> Stream.chunk_every(2, 1, :discard)
|> Stream.filter(&match?([el, el], &1))
|> Stream.map(&hd(&1))
|> Enum.sum()