Phew, finally got past it. I don't like my code one bit, but it got the correct answers so I'm going to stop.
This was an interesting one - I really did struggle with interpreting the instructions, but Digan & Dawn helped out!
Nice opportunity here to do some sorting algorithms - curious to see how others have solved this!
The first macro just splits this between the first character of every pair, and the remainder - so that the remainder can be processed in the next round.
The second macro looks for things like shorter lists; characters that match etc. This outputs the fails and the successes and any pairs that need an int x to be repaced by [x]
This third macro does exactly that replacement:
Putting this all together for part 1:
(BTW - I've been using files to make it easier to test these macros)
Part 2:
Part 2 is just a sort on part 1. So if you consider that part 1 is a > operator - then you can do a simple bubble sort by running part 1 multiple times.
top level:
The first level of this sort takes advantage of the fact that Alteryx works in sets. So the first time it compares the pairs of rows starting from row 1. If any comparison fails, then it switches the order.
Then it does the same but skips row 1 (i.e. instead of comparing 1 &2; and 3&4 - instead it compares 2&3; 4&5)
Then does this in a loop until no rows are being re-ordered by the sort.
Each of these macros is just part 1 essentially:
Pair | Sub-Pair | TextID | data |
1 | 1 | 1 | [ |
1 | 1 | 2 | 1 |
1 | 1 | 3 | ] |
2 | 2 | 1 | 1 |
Pair | Sub-Pair | TextID | data |
1 | 1 | 1 | [ |
1 | 1 | 2 | 1 |
1 | 1 | 3 | ] |
2 | 2 | 0.9 | [ |
2 | 2 | 1 | 1 |
2 | 2 | 1.1 | ] |
Finally done(this is my last challenge).
https://github.com/AkimasaKajitani/AdventOfCode/tree/main/2022