blob: 384a15fe200a7cc6c4daeaad7aeb2e141ab80796 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
start = File.read!("inputs/day10.txt")
lookAndSayStream =
Stream.iterate(start, fn current ->
Regex.scan(~r/(\d)\1*/, current)
|> Enum.map(fn [seq, _] ->
length = String.length(seq)
type = String.at(seq, 0)
"#{length}#{type}"
end)
|> Enum.join()
end)
[fourtiethEntry] = Stream.drop(lookAndSayStream, 40) |> Enum.take(1)
IO.puts("Fourtieth Entry Length: #{String.length(fourtiethEntry)}")
[fiftiethEntry] = Stream.drop(lookAndSayStream, 50) |> Enum.take(1)
IO.puts("Fiftieth Entry Length: #{String.length(fiftiethEntry)}")
|