General Discussions

Discuss a wide range of topics! Questions about the Alteryx Platform should be directed to the appropriate Product discussion forum.

Advent of Code 2021 Day 7 (BaseA Style)

jdunkerley79
16 - Nebula
16 - Nebula

Discussion thread for day 7 of the Advent of Code - https://adventofcode.com/2021/day/7

 

 
 
 
 

cute-crab-paint-by-number.jpg

20 REPLIES 20
bflick
7 - Meteor

A nice break from all the iterations

Spoiler
I think I've used the generate row tool more times this contest then I've ever used it before.
Went with a brute force approach. Used generate rows to create every possible position and then calculated the fuel cost. Sorted for the min fuel cost per possible position.
bflick_0-1638853918774.png

 

clmc9601
12 - Quasar

More generate rows!

 

Spoiler
I only considered positions in the 25%-75% percentiles to save processing speed. I let the batch macro calculate the fuel used for each position and output the result.

Screen Shot 2021-12-06 at 10.15.46 PM.pngScreen Shot 2021-12-06 at 10.16.00 PM.png
NicoleJohnson
14 - Magnetar
14 - Magnetar

Nicole's pro tip for today: Pay attention to the field length in your initial data input. 254 characters is not enough, and you will waste 10 minutes questioning everything you ever knew about Alteryx before realizing this. #AskMeHowIKnowThis

 

Spoiler
I don't often find reasons to use the Running Total tool, but by golly, Part 2 of this challenge was built for it. Gold medal for you, Running Total!! 
NicoleJohnson_0-1638855267130.png

 

Cheers!

NJ

joshbennett
11 - Bolide

Nice and simple one today. Generate Rows has been da real MVP.

 

Spoiler
joshbennett_0-1638856148466.png

 

cgoodman3
13 - Pulsar
13 - Pulsar
Spoiler
Oh why is there not a factorial function in the formula tool?
I initially created the generate rows to get the factorial after my calculation of fuel = abs ( start position - end position ), however this was too slow as it just explodes the data unnecessarily. So moved it earlier in the workflow and then joined on only the required values.

cgoodman3_0-1638856887790.png

Also got to use my input macro! But I didn't wake at 5am so lost out on the speed points!

edit: I’ve just realised we are not solving a factorial in part two as n! = n*(n-1)! And we are adding consecutive values not multiplying. Well at least I was doing the right thing in my solution just calling it the wrong thing!

Chris
Check out my collaboration with fellow ACE Joshua Burkhow at AlterTricks.com
cgoodman3
13 - Pulsar
13 - Pulsar

 

Spoiler
Dang! I like how @NicoleJohnson used running total, as you've already generated all the numbers i.e. you've calculated the abs(position - new position) via the generate rows so you just need to apply the running total to get the equivalent of the factorial.

Plus how @bflick just evaluated it as abs(position - new position) * (abs(position - new position)+1)/2

cgoodman3_0-1638857805537.gif

Edit: there’s an even better way, part 1 is just the median of all the starting positions and in general part 2 can be evaluated to the mean (+/-1) 😲 https://www.reddit.com/r/adventofcode/comments/rars4g/2021_day_7_why_do_these_values_work_spoilers/?...

 

 

Chris
Check out my collaboration with fellow ACE Joshua Burkhow at AlterTricks.com
kelsey_kincaid
11 - Bolide

I need to read the directions more carefully - I put in the position instead of the fuel amount and couldn't figure out my "mistake" for 30 minutes 😩In hindsight I probably didn't need the batch macro.

 

Spoiler
kelsey_kincaid_0-1638858147884.png

 

kelsey_kincaid_1-1638858163584.png

 

 

AkimasaKajitani
15 - Aurora

At Day07, I use the Generate Row tool to make all positions. 

 

Spoiler
At star2, it takes too long time to calculate Factorial. So I use the batch macro to do it and it takes 20 minutes to calculate it.
AkimasaKajitani_1-1638865571656.png

For star2 macro:
AkimasaKajitani_2-1638865603553.png

 

 

GitHub

https://github.com/AkimasaKajitani/AdventOfCode/tree/main/2021

 

 

 

LiuZhang
8 - Asteroid
Spoiler
7 - 1.pngPart 2Part 2

Cannot escape the mindset of using macro now. After missing the straight line formula, I am glad to be able to use formula for arithmetic sum today.