Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

General Discussions

Discuss any topics that are not product-specific here.

Advent of Code 2021 Day 5 (BaseA Style)

jdunkerley79
ACE Emeritus
ACE Emeritus

Discussion thread for day 5 of the Advent of Code - https://adventofcode.com/2021/day/5

18 REPLIES 18
cgoodman3
14 - Magnetar
14 - Magnetar

@grossal 👏 going the extra step to use a count records instead of being lazy and using browse anywhere to get the total records.

Chris
Check out my collaboration with fellow ACE Joshua Burkhow at AlterTricks.com
danilang
19 - Altair
19 - Altair

Lulling us into a false sense of security with a relatively easy one on Day 5!

 

And I've forgotten even if I went to high school, let alone any math I may have done there!

 

Spoiler
The delta on the diagonals is always +/- 1 along both axes.  Once you generate the points along one axis, you can use a multi-row(one of my favorite tools) to number the points and use the point number to calculate the offset from the start along the other.
danilang_0-1638708804592.png

 

Edit: I guess I did go to high school and something stuck since I used the word "delta" in the spoiler 

 

Dan

Aguisande
15 - Aurora
15 - Aurora

I have to pass today, I couldn't understand the problem.

afv2688
16 - Nebula
16 - Nebula

Nice one for today 🙂

 

Spoiler
Sin título.png
LiuZhang
9 - Comet
Spoiler
5 - 1.png5 - 2.png5 - 3.png

Realise using straight line formula will probably made it easier. Since direction doesn't seem to matter, sort from low value to higher value may simplify things as well.

joshbennett
11 - Bolide
11 - Bolide

Have you ever found yourself making a macro for 15-20 minutes on auto-pilot before you realize you don't need a macro? Huh? Oh yeah, me neither...

 

Ugh, I struggled a bit initially with part 2 until my wife (who teaches math/science) was gracious enough to re-teach me y=mx+b (which she was quite excited to see make an appearance "out in the wild", let me tell you). After thinking about it through this lens, it was frustratingly simple.

 

Spoiler
joshbennett_0-1638857033851.png

 

 

SeanAdams
17 - Castor
17 - Castor

My solution is very similar to @afv2688 and @patrick_digan 

(oh, and I'm using a few of the shared macros that folk have posted like the downloader and the switcher - thank you!)

 

 

Spoiler

- First split out the data into unique X&Y values using a regex
- Then split this into rows which are horizontal (constant Y) vs. any other line
- For the horizontal lines - iterate over Y since X does not vary - for example, the line Y=3
- For all other lines - iterate over X using the formula Y =  mX + C.    m is found using the (Y2-Y1)/(X2-X1) gradient function; and then c can be found by substituting any known X,Y combination into the formula above once m is known

- Once you've created all the points - you then just need to count how many times any given point occurs - so Part 1 is identical to part 2, but part 1 just excludes diagonals.

SeanAdams_0-1639241231366.png

 




 

 

caitlynmcintyre
9 - Comet

From now on I'm building something that works with the example data, then plugging in my data. Saves so much time.

 

 

Spoiler
caitlynmcintyre_0-1639626491403.png


I'm sure there's a more mathematically sound way to do this but it works!

 

 

Mchappell67
9 - Comet

I guess I took more of a brute-force approach; similar to other solutions, but didn't use y=mx+b (been WAY too long since school).

 

Mchappell67_0-1639934385779.png

 

Oh, well - got the right answers...

 

Mark

 

Labels