Advent of Code - Day 1

I’m doing this too and my solution is very similar to other ones already posted.

I’m fairly new to Elixir and only using it as and when I can for a side-project so I learnt a few new things…

  1. Stream.cycle() was new to me and I had to Google to find it.

  2. Enum.reduce_while was also a new discovery but at least I found this one by looking through the documentation.

  3. List is really slow and MapSet is really fast when checking for existing items. My first solution used List and was fine for the tests I built but I thought that I had a bug and an infinite loop when I ran the full set of data for the challenge. Once it eventually finished I thought that there must be a faster way and looked at the documentation.

Overall it was a fun little challenge and exactly what I hoped it would be… something to get me to learn new things, not just a test to see if I know it all.

I’m really looking forward to watching José’s Twitch streams about these challenges too.