Day 12
This commit is contained in:
@@ -47,4 +47,14 @@ defmodule Aoc2023.Common do
|
||||
end
|
||||
|
||||
def transpose(l), do: l |> Enum.zip |> Enum.map(&Tuple.to_list/1)
|
||||
|
||||
def collapse(enum, v) do
|
||||
enum
|
||||
|> Stream.zip(enum |> Stream.drop(1) |> Stream.concat([nil]))
|
||||
|> Stream.filter(fn {a, b} -> a != v || b != v end)
|
||||
|> Stream.map(pipe(elem(0)))
|
||||
end
|
||||
|
||||
def repeat(lst, 0), do: []
|
||||
def repeat(lst, n), do: Enum.concat(lst, repeat(lst, n - 1))
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user