QuinnWilton

QuinnWilton

Advent of Code 2019 - Day 7

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 join it by following this link and entering the following code:

39276-eeb74f9a

Most Liked

bjorng

bjorng

Erlang Core Team

Here is my solution.

In part 1, I spent a significant amount of the time to implement my permutations function to lazily generate all phases.

In part 2, I spent some time before I realized that it would have been much easier to run each of the amplifiers in their own Erlang process and rewrite input/output to use message passing. Oh, well! I didn’t do that refactoring, but made the machine suspend on an output operation and saving the IP to make it possible to resume it later when I had new input for it.

aaronnamba

aaronnamba

Very nice, super clean. I did want to try processes + messages, which would have been the Elixir/Erlang way, but I am just not that comfortable with all that stuff yet.

aaronnamba

aaronnamba

Part 1 was real easy, even though I haven’t bothered to fix up my Intcode computer like some of ya’ll have.

Part 2 actually wasn’t difficult either (just have to save state), except that both of the examples did not halt for me. After a while, I gave up trying to fix them and just ran the actual input and it worked. (Update: I realized that I have only been saving the instruction pointer value and not the memory. I am going to fix that real quick, but why did that even work??)

Code here, but I’m guessing our solutions for these intcode computer problems are just going to diverge more and more over time.

sasajuric

sasajuric

Author of Elixir In Action

This was a fun challenge! My solution is completely sequential. I solved part 1 as a special case of part 2.

Nice! I also went for lazy permutation. Here’s my approach.

Where Next?

Popular in Challenges Top

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
bjorng
My solution finishes both parts in 5 seconds on my computer. That time should be possible to reduce by optimizing my rather naive tilt/2 ...
New
rugyoga
Fairly straightforward Dijkstra’s algorithm import AOC aoc 2023, 17 do def compute(input, candidates) do {{max_row, max_col}, ite...
New
New
Aetherus
This topic is about Day 5 of the Advent of Code 2020 . Thanks to @egze, we have a private leaderboard: https://adventofcode.com/2020/le...
New
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
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
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

Other popular topics Top

vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
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
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
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
sacepums
Hey guys. I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
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
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New

We're in Beta

About us Mission Statement