Advent of Code 2015 Day 5 Part 2
Mix.install([
{:kino_aoc, "~> 0.1"}
])
Get Inputs
{:ok, puzzle_input} =
KinoAOC.download_puzzle("2015", "5", System.fetch_env!("LB_SESSION"))
My answer
puzzle_input
|> String.split("\n")
|> Enum.count(fn word ->
has_repeat =
Regex.run(~r/(.{2,}).*\1/, word)
|> then(&!is_nil(&1))
has_between =
Regex.run(~r/(.).{1}\1/, word)
|> then(&!is_nil(&1))
(has_repeat and has_between)
end)