bjorng

bjorng

Erlang Core Team

Advent of Code 2019 - Day 16

Note: This topic is to talk about Day 16 of the Advent of Code 2019.

There is a private leaderboard for elixirforum members. You can join it by following this link and entering the following code:

39276-eeb74f9a

Most Liked

bossek

bossek

If somebody is missing Stream solution of the part 2 today, here it is.

bjorng

bjorng

Erlang Core Team

Here is my solution.

I solved part 1 in the morning, but my program needed 17 seconds to find the answer.

That started my day of premature optimization. In hindsight, the problem with my original solution was probably that I used streams in a non-efficient way. I reimplemented part 1 with my own implementation of lazy lists. I hoped that it would be useful for part 2. It wasn’t.

When I saw that all examples and my input had offsets in second half of the input, I knew how to solve it. Unfortunately I did some more premature optimization and didn’t get it to work. I then took a look in the forum and saw all my premature optimizations were totally unnecessary. I wrote my own solution inspired by a quick look at @sasajuric’s solution.

My solution solves part 1 in 0.2 seconds and part 2 in about 3 seconds.

ferd

ferd

Author of Property-Based Testing with PropEr, LYSE, & Erlang in Anger

Day 16 really sucked.
I didn’t figure it out. I wouldn’t have figured it out. I just don’t know or didn’t recall the magical matrix properties I’d have needed to figure out from this specific input to make it work, so I spent a couple of hours floundering to get you this useless video that will teach nothing and that you should probably not watch:

I’m still bitter about this day being a damn loss of all my free time, it felt like failing a shitty whiteboard programming interview.

sasajuric

sasajuric

Author of Elixir In Action

This is my solution for day 16. I’m not happy with part 2, because the solution only works if the requested sequence is in the second half. On the upside, part 1 is reasonably fast (about 400 ms on my machine).

sasajuric

sasajuric

Author of Elixir In Action

What if the input starts with 0000000? :slight_smile:

370ms part 1
2.1s part 2

Where Next?

Popular in Challenges Top

JEG2
Note: This topic is to talk about Day 9 of the Advent of Code. For general discussion about the Advent of Code 2018 and links to topics ...
New
antoine-duchenet
Everything went smoothly today. Nothing to change to solve part 2 because I already used memoization for part 1 (it looked like an AoC e...
New
DmitriyChernyavskiy
Hello everyone, I’m a new in elexir and functional language. I’m trying to implement Websocket interraction with server. On first layer...
New
bjorng
This topic is about Day 18 of the Advent of Code 2021. We have a private leaderboard (shared with users of Erlang Forums): https://adve...
New
maennchen
Ok, that was a rough one today. I haven’t found a way to improve the algorithm further. Part 1 runs in .5 seconds, Part 2 in ~ 5 minutes...
New
groovyda
Today’s challenge for me was about using reduce: defmodule Prob5 do def move([[h1 | rest] = _list1, list2]) do [rest, [h1 | list2]...
New
bjorng
Note: This topic is to talk about Day 23 of the Advent of Code. For general discussion about the Advent of Code 2018 and links to topics...
New
lud
Gosh this one took me sooo much time. At first I was trying to iterate each digit independently on the input A number to make digits cha...
New
seeplusplus
Hello all, hopefully I post this before someone else does and I don’t dupe. IMO Day 4 was much easier than Day 3 (yay, I can sleep befor...
New
coen.bakker
Since I started using Elixir, I have benefited greatly from being able to study various open-source projects. The codebase of LiveBook, i...
New

Other popular topics Top

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
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
AstonJ
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New

We're in Beta

About us Mission Statement