Free Trial

General Discussions

Discuss any topics that are not product-specific here.

Advent of Code 2024 Day 6 (BaseA Style)

AlteryxCommunityTeam
Alteryx Community Team
Alteryx Community Team

Discussion thread for day 6 of the Advent of Code - https://adventofcode.com/2024/day/6

22 REPLIES 22
JoshuaB
Alteryx
Alteryx

This is precisely when you realize Day 6 is hard 😂 No Solutions yet posted!

Joshua Burkhow | Chief Evangelist @ Alteryx | Follow me on LinkedIn and Twitter
ScottLewis
11 - Bolide

I'm reasonably confident in my solution. It's just that I estimate the runtime at ~600 hours.

That was the point at which I chose sleep.

BransonJamesFarley
8 - Asteroid

😂😂

CoG
14 - Magnetar

My solution, Part 1 is fairly quick, but Part 2 took 1hr and 10min to run:

 

My First Solution:

Spoiler

Main Workflow:

Spoiler
Main.png

Move Guard (Iterative Macro):

Spoiler
Move Guard.png

Part 2: Place Obstacles (Batch Macro w/ Move Guard macro nested inside):

Spoiler
Tried to optimize in a few different ways. One of the biggest optimizations that can be made is recognizing that obstacles only need to be place on the original path of the guard, otherwise, it will never be encountered and a loop will never be generated.

Place Obstacles.png

Amazing Solution (Thanks to @gawa for the idea to not nest macros): With the power of smart optimizations and memoization of the guard's corner stops this workflow solves Day 6 in 2 minutes and 30 seconds!!!:

 

Spoiler
Main V2.png

Part 1 Macro (Move Guard V2):
Spoiler
Move Guard V2.png
Part 2 Iterative Macro (Move Guard V3 - handles adding 1 obstacle):
Spoiler
Move Guard V3.png

Pretty Picture of Part 1 Guard's Trajectory:

Guard Path.png

Sebastian_Chaieb2
9 - Comet
9 - Comet

This one is really hard 😂

First Part was running 17min and Second I have to fine tune as it will run forever :P

 

Spoiler
Day6_start1.png
And iterative macro
Day6_start1_Iterative.png

mmontgomery
11 - Bolide
11 - Bolide

Sheesh. More in spoiler

Spoiler
P1 wasn't too bad to map out the logic and brute force your way to unique steps
P2 took a while to figure out the setup that got me exceptionally close to the answer (off by single digits) and just guessed til I got it.

My approach was this, I needed four datasets:
1. Main map;
2. Existing boundaries (outside map listed as E for exit that I generated and # for current blockers);
3. Current Starting point;
4. Individual steps I got from P1 used a new boundary to generate a brute force batch macro

The goal was to determine if a given step would result in E for exiting the map or # for hitting a loop. My logic for hitting a loop was a point and direction combo that was previously seen in the path.

To make the batch macro more optimal (45 minutes vs endless) I just jumped ahead from any given point to the nearest boundary it would hit: # or exit E. If it hit a boundary in play, generate the new point similar to P1 and loop, if it hit an exit then the macro would end, as well as running into a previously seen path and direction.

P1.pngP2_Iterative_Feed.pngP2_Job_Run.pngP2_Macro.png
DataNath
17 - Castor
17 - Castor

Very satisfying to get this one cracked. Originally didn't have a clue how to tackle it but tested out a few approaches and got there in the end. P1 runtime was 1.7 seconds, P2 was 1 hour 42 mins. A huge thanks to @CoG for the golden tip on optimising iterations!

 

Spoiler
A couple of useful pointers:
1) Keep a stored list of visited points and the direction - a loop is when you return to a matching point & direction
2) There's no need to run through every point - with the right logic you can 'jump' to the next obstacle-1, and generate a list of 'visited' tiles
3) You only need to insert extra obstacles at tiles you visited on Part 1 as you can't get to the rest of the grid

Main workflow:

Day 6 - Workflow.png

Part 1 iterator:

Day 6 - P1 Iterator.png

Part 2 batch:

Day 6 - P2 Batch.png

Part 2 iterator:

Day 6 - P2 Iterator.png

 

gawa
16 - Nebula
16 - Nebula

Brute force way. For part2, it'll take 8 hours in my computer😂😂😂

 

(Edit_ve2)

Instead of nested macro(Iterative Macro inside Batch Macro), I made attempt by single Iteration Macro, that run within 15min.

I maintain the same algorithm(brute force) as previous attempt but running time got much faster. 

Nested Macro is 'easy for human to understand' but 'not easy for Alteryx to process'...maybe. 

AkimasaKajitani
17 - Castor
17 - Castor

Solved!

 

Day 6 is toooooo hard. Normally this difficulty puzzle is served after day15. 

 

Spoiler
Day 6 is toooooo hard. Normally this difficulty puzzle is served after day 15. But I finally solved day 6 at 10 minutes before the start of day 7.


AoC_2024_06_03.png
Part 1 macro (moving the path step by step):

AoC_2024_06_04.png

This is not fast, but it is needed for part 2 input.

Part2 Batch macro(Place obstacles one by one from the path of Part1 and start the infinite loop detection macro):


AoC_2024_06_05.png

Part2 finding the infinit loop macro : 

Part 1's step by step macro is toooooo slow, so I had to re-create the macro. This macro will jump as far as possible in a straight line. But it is still slow. It took 2.5 hours to solve.

AoC_2024_06_06.png

To solve faster, I think that the gawa's parallel approach is needed.

 

Labels
Top Solution Authors