sneako

sneako

Advent of Code - Day 1

Note by the Moderators: This topic is to talk about the first day of the Advent of Code.

For general discussion about the Advent of Code 2018 and links to topics of the other days, see this topic.


Nice one, mine came out quite similar: solution & test

Most Liked

simon

simon

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.

yawaramin

yawaramin

Just finished Day 1 both parts, the fun thing with Advent of Code is that basically anything that deals with reading an input file and doing some calculation on it is a prime candidate for File.stream and then Stream processing–we have it really easy in the Elixir world.

arhyth

arhyth

I’ve been working in elixir for a year now and most of the language “constructs” I used in this day’'s solutions including the ones you mentioned were all new to me. My implementation for the second problem used lists and was very slow. I tried it with mapsets after looking at others solutions and wow what a difference.

After this first day, I’m also looking forward to the next days and to Jose’s twitch streams.

Where Next?

Popular in Challenges Top

bjorng
This topic is about Day 15 of the Advent of Code 2021. We have a private leaderboard (shared with users of Erlang Forums): https://adve...
New
dominicletz
This topic is about Day 8 of the Advent of Code 2020 . Thanks to @egze, we have a private leaderboard: https://adventofcode.com/2020/le...
New
bjorng
This topic is about Day 6 of the Advent of Code 2021. We have a private leaderboard (shared with users of Erlang Forums ): https://adve...
New
Aetherus
This topic is about Day 7 of the Advent of Code 2020 . Thanks to @egze, we have a private leaderboard: https://adventofcode.com/2020/le...
New
liamcmitchell
A frustrating one for me. I spent a long time trying to understand why some combinations resulted in fewer presses and struggled to keep ...
New
bjorng
Here is my solution for day 4: https://github.com/bjorng/advent-of-code/blob/main/2024/day04/lib/day04.ex
New
bjorng
Note: This topic is to talk about Day 5 of the Advent of Code 2019. There is a private leaderboard for elixirforum members. You can join...
New
Aetherus
I spent 3 hours struggling in part 2, until I noticed a very basic mistake :joy: Here’s my code: https://github.com/Aetherus/advent-of-...
New
adamu
Nobody’s doing Advent of Code this year? :grinning_face_with_smiling_eyes: I might do the first week or so. For Day 1, first I solved i...
New
igorb
Today is a brute-force day: advent-of-code-2024/lib/advent_of_code2024/day6.ex at main · ibarakaiev/advent-of-code-2024 · GitHub Takes a...
New

Other popular topics Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30877 112
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43622 214
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New

We're in Beta

About us Mission Statement