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:

2
Post #11
qhwa

qhwa

I’m stuck on part 2.

I want to find the solution with program. So I made a path finding function. It outputs all (in my mind) possible routes, in which another function searches for the ABC pattens.

It works on the small examples provided, but sadly not with my puzzle input. I think there might be some issues with my path finding algorithm. However I couldn’t figure it out in hours.

The code looks ugly at this moment. :joy:

rewriting it.

0
Post #12
ferd

ferd

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

Did the entire thing fully automated using some brute-force probabilistic searches to break down the full path into subroutines and then re-combine the valid subroutines into a sequence of calls that re-create the original program.

One of my biggest struggles there was just remembering the limitations of my intcode computer in that it only handles integers and not strings!

0
Post #13
qhwa

qhwa

Turns out my pattern searching approach was not working correctly. Finally get it perfectly working! Tired but really happy!

0
Post #14
— All posts loaded —