Discussion thread for day 6 of the Advent of Code - https://adventofcode.com/2022/day/6
Build to scale and you'll never fail
Learned my lessons from last year, when in doubt make everything into rows.
I used a long formula for the first part knowing it wouldn't work for more than four letters. Naturally, the second part involved more letters 😂
My take on this using 4 tools and string functions
Happy Analyzing Cheers and have a nice day!
The first day I put my alarm on snooze and I over sleep by a bit so miss out on the opportunity to take on @bflick and @clmc9601 for the fastest solve.
@cgoodman3 maybe you already did this, but Excel can help assemble the long expressions! Slightly less manual than typing them by hand.
Long way around with a Multi-Row Formula for the solve... then a quick Tool Golf refactor for 7 tools (both parts). Enjoyed the quicker run after yesterday's almost-mind-bender!
Slight modification to improve the tool golf score and to make it dynamic.
1) Created a user constant "StringLength" which the user can specify to modify the data, which is used in the formula and filter tools2) Used generate rows to explode the input into many rows3) Used substring to walk along the input the desired number of letters
My solution.
Part 2 have a large IF statement.
I have to create a very lengthy Multi-row formula. Will try to do it in a better way.
I used a hard-coded multi-row formula that wouldn't work for tons of letters for part one, then got stuck for a bit on part 2 until I used the multi-row formula tool more like a running total and assigned points based on where letters matched in the previous sequence. Not the simplest, but it made sense in my head!
Here's my stab at this. Wasted a load of time faffing around with an enormous Multi-Row Formula to try and chop out a couple tools but eventually gave up in the hopes of slipping in another hour of sleep.
Old Style!
My 2nd solution.
There are 4 tools using by Generate row.
If it went more than 14, that'd be a lotta lines on the 'IF'.
My solution, could have been made with a bit less tools maybe
Finally joining in too.
I probably made it overly complicated with a batch macro in an iterative macro.
Edit: Omg - is my solution overly complicated
Day 6 done ! ✔️
I feel like it was too easy compared to yesterady. A bit worried about tomorrow ...
Probably could have minimised the number of tools, I tend to always want to unique ID everything along the way but I suppose it's good practice!
Felt a little manual when I was copy and pasting in the multi-row but that seems to have been most people's approach today.
Here's my first attempt:
There must be a single formula solution using RegEx. Will look for it now
Might be a bit of an overcomplication but I've built so many iteratives recently this might actually be faster for me than messing around in formulas.
Never tried so many iterations, a first for me.
My first attempt, which uses iterative macro, is based on intuition. Part 1 and Part 2 are similar.
Will look through others' solutions especially the crazy Regex / Formula tool ones
Combining the formula and the Generate row into a single Generate Row is a super idea @AkimasaKajitani , can you share how you did that?
Tried at first to do a massive if-else but finally came round to doing some regex 😅
Solution with one tool
Here is the Generate row setting of my 2nd solution. I think that the expression is too long.
@AkimasaKajitani neat solve! It reminded me of @AdamR_AYX 's solve from weekly challenge 59 about anagrams. I think you could apply similar logic here:
Iterative macro. the only difference is changing the match string number
Tool golf edition. 2 tools each for parts 1 and 2, with just changing the number of characters to evaluate from 4 to 14. All of the processing can be done with a Generate Rows tool, and then a sample tool for the output.
I'll be honest this was a very lazy solution on my end (which I'm blaming on being ill). I initially used a multi row formula for star 1 and not wanting to do the same for star 2 I built a macro that works in essentially the same way
@estherb47 Cool RegEx solution! I wanted to write like this but I can't write like such a complex one.
This is the simplest regex I can think of for this. My 1st attempt was clunky with multirow formulas to get the stars. This is better I think.
Multi-row madness like many others
Wish I hadn't gotten such a late start on this one - it was a nice pick-me-up after Day 5! Excited to tool golf this one - I already have several ideas.
@DavidP nice use of the regex lookahead there. I had to put it into regexr to work out what it was doing.