Discussion thread for day 5 of the Advent of Code - https://adventofcode.com/2021/day/5
I guess my teachers were right and we did need to remember y = mx + b. A great opportunity to use the generate rows tool!
Lots of Generate Rows!
Again another day where the part two wasn't that much more difficult than the first part. I just got stuck down a rabbit hole as the first attempt at building it out I had forgotten that there could be diagonals in both directions, so it's not just as case of generating the x.y co-ordinates as you need to factor in increasing and decreasing values in x and y and because I was using a join based on position instead of calculating the order needed to get my ordering correct. So while most of the time it is beneficial being able to use assumed sort in Alteryx if you are relying on a particular order you can't! So that resulted in the second part taking much longer than the first!
Solved for stars and then played tool golf to get it down to this combination... Though I'm a bit disappointed in myself now that I see @bflick bringing back y=mx+b. Missed out on an opportunity to finally use that particular tidbit of knowledge! 😂
Cheers!
NJ
I use only one Generate Row tool to make diagonal line. It is a pretty forceful way. But it took long time to make the condition expression.
GitHub
https://github.com/AkimasaKajitani/AdventOfCode
Wow, taking me back to HS math.
abs(ATAN2([y1]-[y2], [x1]-[x2]))*180/3.14 (to find 45 degree diagonal lines)
y=mx+b
My solution resembles @bflick 's solution
Very straight forward this time. Could have simplified the first one, but I'll need breakfast first.
https://github.com/dsmdavid/AdventCode2021
@grossal 👏 going the extra step to use a count records instead of being lazy and using browse anywhere to get the total records.
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!
Edit: I guess I did go to high school and something stuck since I used the word "delta" in the spoiler
Dan
I have to pass today, I couldn't understand the problem.
Nice one for today 🙂
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.
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.
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!)
From now on I'm building something that works with the example data, then plugging in my data. Saves so much time.
I'm sure there's a more mathematically sound way to do this but it works!
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).
Oh, well - got the right answers...
Mark