Day 13
This commit is contained in:
@@ -37,7 +37,9 @@ defmodule Aoc2023.Common do
|
||||
def lines(x), do: String.split(x, "\n")
|
||||
|
||||
def head([head | _]), do: head
|
||||
def head([]), do: nil
|
||||
def tail([_ | tail]), do: tail
|
||||
def tail([]), do: nil
|
||||
|
||||
def lcm(a, b), do: div(abs(a*b), Integer.gcd(a,b))
|
||||
def lcm(ls), do: ls |> Enum.reduce(&lcm/2)
|
||||
@@ -55,6 +57,6 @@ defmodule Aoc2023.Common do
|
||||
|> Stream.map(pipe(elem(0)))
|
||||
end
|
||||
|
||||
def repeat(lst, 0), do: []
|
||||
def repeat(_, 0), do: []
|
||||
def repeat(lst, n), do: Enum.concat(lst, repeat(lst, n - 1))
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user