xfix

xfix

Advent of Code 2019 - Day 17

Note: This topic is to talk about Day 17 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

xfix

xfix

Giving a hint, just in case you have the same bug as I had in my interpreter (and took a while to figure out). Specifically I constructed the output by doing [x | xs]. This however meant the output was reversed, but as it happens, this wasn’t really an issue until Day 17 part 1 (seriously, I only realized the issue now, as it happens, no previous tasks cared about whether the output was reversed or not).

If you have two newlines at the start of an output, that’s the issue. Those should be at end, not at the start.

sasajuric

sasajuric

Author of Elixir In Action

Wow, this was very finicky!

I refused to solve the problem manually. It was clear to me in the morning that it’s not tricky in the algorithmical sense, but that there will be many fine-print details to pay attention to.

I ultimately solved it in a brute-force fashion. I did a depth-first search to find complete paths, then on each path I look for a valid program. This boils down to trying all possible triplets of main routines until I’m able to encode the entire thing into three routines, none of which exceeds the desired length.

The code is available here. It could use a bit more of a cleanup, can’t say it’s my finest hour :slight_smile:

sb8244

sb8244

Author of Real-Time Phoenix

That’s impressive! Great work on doing the actual automated solution here.

I don’t think I did anything special—it’s a pretty standard solution. I was a bit frustrated because I knew the right path to do when only 25 people had solved both parts. But I had flipped my graph around (r, c iteration instead of c, r) and it completely changed my result. So I spent about 3 hours on it in the end. Once I realized the inversion mistake, I had the answer in about 10 minutes :frowning:

Where Next?

Popular in Challenges Top

LostKobrakai
This topic is about Day 9 of the Advent of Code 2020 . Thanks to @egze, we have a private leaderboard: https://adventofcode.com/2020/le...
New
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
sneako
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...
New
QuinnWilton
Note: This topic is to talk about Day 7 of the Advent of Code 2019 . There is a private leaderboard for elixirforum members. You can joi...
New
bjorng
Note: This topic is to talk about Day 13 of the Advent of Code 2019. There is a private leaderboard for elixirforum members. You can joi...
New
bjorng
Here is my solution for day 1 of Advent of Code: defmodule Day01 do def part1(input) do all = parse(input) {first, second} = E...
New
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
bjorng
This topic is about Day 10 of the Advent of Code 2021. We have a private leaderboard (shared with users of Erlang Forums ): https://adv...
New
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

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
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
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
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
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
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
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New

We're in Beta

About us Mission Statement