simon

simon

Advent of Code - Day 4

Note by the Moderators: This topic is to talk about Day 4 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.


Day 4 is in the bag after a bit of a struggle.

For part 1 I had two minutes which has the same count of times asleep for a guard and typically (well, maybe fortunately) my code returned the second minute value which was rejected. I changed my code to look for the earliest minute with the maximum count and all was well.

Part 2 was all down to me and a stupid code mistake but my test using the sample data was passing which threw me off for a while (the same problem happened with part 1). I should probably add my own test data in so that my tests are more comprehensive.

My code was more structured today (I’m using more functions and also a couple of structs) but I’ve still got some Enum.reduce/3 calls in my pipelines which I need to move into their own functions.

And for variety, unlike using regex to parse the data strings which I did yesterday, today I used String.slice/2.

Still need to document things properly however.

Code is at https://github.com/simon-wolf/advent-of-code-2018/blob/master/lib/advent_of_code_2018/day_04.ex

Most Liked

sasajuric

sasajuric

Author of Elixir In Action

I’m not committed to AoC this year, but today I discussed the task with a friend, so I solved it. My solution is here.

Where Next?

Popular in Challenges Top

sasajuric
Note: This topic is to talk about Day 12 of the Advent of Code. For general discussion about the Advent of Code 2018 and links to topics...
New
sasajuric
Note by the Moderators: This topic is to talk about Day 5 of the Advent of Code. For general discussion about the Advent of Code 2018 an...
New
New
adamu
I said I was on a break, but I took a sneak peak and it looked fun so… Part 1 completes in half a millisecond with a single pass of the ...
New
bjorng
Note: This topic is to talk about Day 9 of the Advent of Code 2019. There is a private leaderboard for elixirforum members. You can join...
New
bjorng
This topic is about Day 9 of the Advent of Code 2021 . We have a private leaderboard (shared with users of Erlang Forums): https://adve...
New
Aetherus
Finished Day 1 with Elixir :tada: Here’s my code: #!/usr/bin/env elixir defmodule Combination do @doc "Yields each combination of 2...
New
woolfred
It is that time of the year again: Advent of Code 2022 :christmas_tree: Day 1 Leaderboard:
New
Qqwy
Note by the Moderators: This topic is to talk about Day 6 of the Advent of Code. For general discussion about the Advent of Code 2018 an...
New
igorb
So… that’s it? Everyone is stuck on part 2? :slight_smile: I looked at Reddit hints and thought I probably wouldn’t have come up with the...
New

Other popular topics Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
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 30048 115
New
yurko
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
sergio
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New

We're in Beta

About us Mission Statement