rvnash

rvnash

Advent of Code 2024 - Day 24

Anyone have a solution to Part 2 today? Part 1 was straight forward, but I can’t figure out a programatic way to do part 2. I understand the properly constructed machine would be a carry-forward adder, so besides visualizing the configuration and looking for mis-wirings I’m not sure how to approach it.

Most Liked

Kevo

Kevo

I think this is closer to the approach I was trying to figure out. Thanks for posting this. It does produce the correct result for my input. I am going to need to spend a bit more time on this to understand it fully and know for sure it’s doing what I think it is.

This is one aspect of elixir code that I haven’t really gotten comfortable with. For basic things the code seems so elegant and straightforward, but once things get complicated I seem to get lost and have a harder time visualizing what is actually getting passed between the functions. I’ve mostly done OOP stuff before and didn’t really experience this before. Maybe it’s more to do with the nature of Advent of Code than elixir in general. IDK

I would love a tool that could show visually what the parameters look like when you mouse over functions. I think that would be super cool and help a lot in these cases.

lud

lud

I plan to do that too tomorrow. Wires should be present at two different places in the graph, as input and output for well known “xyz” names so building a mapping should be possible.

At least I hope :smiley:

liamcmitchell

liamcmitchell

I think that’s how I’ve solved it.

Part 1 example (2.8ms): 2024
Part 1 input (5.0ms): 56620966442854
Part 2 input (96.2ms): "chv,jpj,kgj,rts,vvw,z07,z12,z26"

I make graphs of logic and input wires only, no intermediate names. This lets you easily test if a node is logically equal. I look up the intermediate names from a map when needed.

bjorng

bjorng

Erlang Core Team

I found the answer for my input just a few minutes ago, but I don’t have any code to share yet. (Too messy and it doesn’t solve the complete problem.)

What I did was to programmatically check for mis-wirings for each output (starting with z0). For my input, the first mis-wiring was for z18. Going from that to which wires to swap was not obvious, so I tried to figure it out by manually looking at how the gates were wired. I did a topological sort of the gates, which made it easier to try to understand what was happening.

I managed to figure out which two wires that were likely to fix the problems with z18, and tested that with my program. It fixed the problem and my checker gave me the next incorrect output. I quickly figured out two more pairs.

The final pair had a different kind of mis-wiring, which was harder to figure out manually. At that point I just added a brute-force search, testing swap each possible pair of wires. It finished in a few seconds.

I now think I now how this can be solved programmatically without any need for manual intervention. It might be a couple of days before I’ll have time to try that.

bjorng

bjorng

Erlang Core Team

It turns out that it is viable to do a brute-force search for one pair at the time. My solution finishes in about 8 seconds. I will share my code when I’ve cleaned it up.

Where Next?

Popular in Challenges Top

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
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
sukhmeetsd
All in all, from what I understand, it is better not to use GenServer.cast when we want some concurrent operations to happen for sure, be...
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
stevensonmt
Trying to get more facility with dynamic programming concepts on Leetcode and having an issue I can’t find a way around. It’s a chutes an...
New
gangstead
This is my second year doing AoC in Elixir and my first year doing it with Livebook. When I was doing just plain Elixir I usually set up...
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
Aetherus
Don’t know why the regex ~r/[\W && [^\.]]/x does not work in Elixir. It works pretty well in Ruby. Anyway, here is my solution:
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 16 of the Advent of Code 2021. We have a private leaderboard (shared with users of Erlang Forums): https://adve...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3268 119930 1237
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
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
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
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
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
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New

We're in Beta

About us Mission Statement