diff options
Diffstat (limited to '2015/day10.exs')
-rw-r--r-- | 2015/day10.exs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/2015/day10.exs b/2015/day10.exs new file mode 100644 index 0000000..384a15f --- /dev/null +++ b/2015/day10.exs @@ -0,0 +1,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)}") |