Showing posts with label Advent of Code 2024. Show all posts
Showing posts with label Advent of Code 2024. Show all posts

Tuesday, December 03, 2024

Advent of Code 2024 - Day 2 and 3

I am soooo freaking rusty.  Maybe if I was using Python, it wouldn't be so obvious.  But flipping between regex and general flow, albeit without a good iterative process because I'm using a low/no code platform instead of Python [which includes restrictions around RegEx so my speedy match required some unintuitive reworking], requires more attention than I expected.  I did find my flow a few times which was nice....management doesn't generally lend itself to finding that sweet spot.

My Day 2 solution...I think I could have done a better job by using a multi-row formula tool to look back and forward and apply it across the diffs, but this worked.  Unfortunately....my approach meant that when I tried to build off of it for the second part, I was somewhat locked into a pattern that required some cut and paste.  Pretty much the definition of tech debt and bad architecture.


Laughing is appropriate here... I had the basic pattern for how to exclude a value at a time from my ragged array in mind, but with the initial process I was using, it didn't lend itself to something dynamic.  Instead, I just targeted each value with a separate process [yeah, it won't scale at all] and then eliminated the duplicates.  Not as bad as it looks because it's mostly cut and paste.  It reminded me of the ragged array Secret Santa Python I use once a year for family that excludes closest family and the last year or two of recipients.  That's basically 24 lines of code...a double loop in Python would have been infinitely easier.  But defeated the purpose.  I did generate some product ideas while I was playing around with the layout, so probably worth the weird approach.



And Day 3, both part 1 and part 2.  Part 1 was using some regex to extract a pattern and then parse it to multiply numbers.  Part 2 was a little bit trickier because the pattern had to grab mixed start and end sections that determined whether to evaluate the numbers or not.  That's the part where the Perl regex tripped me up.  A bit of trial and error got it going eventually and then it was the same pattern/parsing as part 1, with the exception that I had to drop in a start and stop word at both ends of the document as my regex wasn't smart enough to deal with a start with no end.



Sunday, December 01, 2024

Advent of Code 2024

The Advent of Code 2024 challenge started because, well, it's Advent.  Two challenges a day, the second one generally built off the answer / pattern involved in the first.  I've played around with it using Python before and that's fairly intuitive.  However, for purposes of eat-your-own-dogfood / stomp-your-own-grapes / spoke-your-own-wheel / et al the goal as an employee of my current company is to use our own software to complete the challenges.

That can be tough as our software is designed for business analyst types when it comes to prep and blend, so it doesn't act exactly like you'd expect a software language to work.  If you're a business analyst type, that's not really an issue.  The tools are probably your language and mental structure of choice.  If your brain has been saturated over 25 years [cough, or more] with VB, C Sharp, Java, Python, Javascript, SQL, and more...well, it's difficult to make that mental shift to needing to do two or three things with separate tools where you might otherwise use a complex line of code.

So it can get complex, but possible.  However, a new challenge this year is that our cloud-based prep and blend tools are available, so rather than using the desktop designer with all the bells and whistles, I'm using the cloud versions.  Don't get me wrong, lots of bells and whistles.  But it's limited to the roughly 50 prep and blend tools across cloud native [works with cloud data in place] and standard modes [traditional engine, although it was second to production].

I'm a glutton for new tastes.  Day 1a and Day 1b are in the can.  I had to do a little bit of data cleansing and I think, like usual, I made it a little more involved than necessary [make it work, then optimize...if you care to, I always say, because it might not have a shelf life long enough to need optimization], but the answers were both right on the first try.

Day 1a - get some absolutely differences between two sorted lists and sum...


Day 1b...same pattern, but find the count of the matches in the second list and multiply that "id" by the count and sum...