cancel
Showing results for 
Search instead for 
Did you mean: 

Advent of Code via SnapLogic IIP

ddellsperger
Moderator
Moderator

I’ve been a pretty big fan of Advent of Code since I found out about it in 2019 and when I started with SnapLogic in 2021, I figured it could be pretty cool to try to use the SnapLogic IIP to solve all (well, not all, but at least some) of the Advent of Code daily puzzles, mostly to learn better how some of the snaps work, but also get more experience designing pipelines since I’m typically working more in the individual snap development.

This year, I figured I’d post about it here in the community, and to see if others have an interest in attempting to solve the daily puzzles on SnapLogic IIP. I think there are a certain level of these problems that ARE solvable via the IIP, and some that aren’t due to some of them which aren’t.

My ground rules for considering a day solved is:

  • Get the input into a pipeline in whatever way possible, either via file download and read, or via Constant snap (My posted examples will use the sample input with Constant snap, but my final solutions typically will use a file reader)
  • No use of the Script Snap (if it can’t be solved without a script snap, it’s considered unsolvable, but you’d be surprised what things you can do without a script snap with our snaps)
  • No use of external services (databases, rest endpoints, etc) as those are likely to have some level of “cheating” associated with them similar to a script snap
  • Basically, using only the transform, flow, and file reader/writer (to read input files, create, delete, read, and write temporary files, and write final output files)
  • Pipe Execs are allowed

I figure this might be something that other members of the community might be interested in doing, if you want to participate, feel free to join in on the conversation, I figure we can probably keep discussion to a single thread and do replies per day? Not sure how many might be interested in this, though.

What is Advent of Code?
From the website:

Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like. People use them as interview prep, company training, university coursework, practice problems, a speed contest, or to challenge each other.

You don’t need a computer science background to participate - just a little programming knowledge and some problem solving skills will get you pretty far. Nor do you need a fancy computer; every problem has a solution that completes in at most 15 seconds on ten-year-old hardware.

If you want to join in, go to https://adventofcode.com and connect one of the authentication mechanisms. (I use github, but you can auth with google, twitter, or reddit as well) Logging in for an account is required so that you can receive input specific to you.

If you plan to join and want to join a leaderboard for this project, feel free to join my private leaderboard with the code 1645534-1249c834.

20 REPLIES 20

ddellsperger
Moderator
Moderator

I’m uploading my Day 1 solution, but I highly suggest trying this out yourself first. I found it to be something that was really hard to split the individual groups of Elves items since in the example, you’re thinking maybe 3 is the most, but as I looked at my input, I saw 10+ items. I kind of used a hack that I learned about the “Group by Field” snap with some other strange properties to do this, but once you have the groups, the rest of this is pretty simple (I think) to solve.
Screenshot of Solution (Part 1 on top, Part 2 on bottom):
image

SLP File:
day01_2022_12_01.slp (28.5 KB)

ddellsperger
Moderator
Moderator

Day 2 was pretty simple with SnapLogic IIP, it was a row-by-row processing (this happens with some of the Advent of Code Puzzles), for the most part, I’m just using a router for the opponent’s option and then mappers to determine my score for the given scenario. This is actually a pretty cool example of simply getting started with using the Router/Union for people who might be new to the SnapLogic IIP. These kinds of puzzles end up being pretty fun to figure basically as soon as I see them, I know the IIP will be a great option for solving this problem.

Screenshot:
image

SLP File:
day02_2022_12_02.slp (29.0 KB)

ddellsperger
Moderator
Moderator

Day 3 was actually another pretty impressive use of SnapLogic, this time I leveraged some really cool properties of data to where I could simply use the expression language to split the letters in the different compartments or rucksacks (depending on the part) and then use a filter + unique to get the one letter that’s common between all of them, by keeping the other compartment/rucksack, that made the unique work better and frankly allowed for less usage of the expression language (which I find to be handy when I’m trying to learn about the different transformation/flow snaps). I also wanted to learn with the In-Memory Lookup for aligning the final item or badge to the score for that item or badge, and I feel like I understand that better now too.

Screenshot:
image

SLP File:
day03_2022_12_03.slp (37.9 KB)

ddellsperger
Moderator
Moderator

Day 4 seemed easier than it probably should’ve been (first full weekend puzzle is usually a tough one in previous years), hardest part is reasoning over the logic for the complete overlap vs. partial overlap, The problem example had some situations where it MIGHT pass locally, but fail with your input due to the few side-tracks, I made some assumptions (that to me felt safe) with how the data was represented, but so far nothing in Advent of Code has really pushed anything beyond a LITTLE bit of semi-advanced expression language at this point, though I feel like I know what’s coming up based on previous years and will probably soon have a situation where there’s some basic programming concept that IIP flow simply doesn’t really work with.

Screenshot:
image

SLP File:
day04_2022_12_04.slp (20.3 KB)