ALTERYX INSPIRE | Join us this May for for a multi-day virtual analytics + data science experience like no other! Register Now

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 2020 - BaseA Style (Day 13)

Jean-Balteryx
14 - Magnetar

Discussion thread for day 13 of the Advent of Code : https://adventofcode.com/2020/day/13

cgoodman3
12 - Quasar
12 - Quasar

Here's my Part A.

 

Spoiler
cgoodman3_0-1607849233790.png


Added in the tools at the end to get to single cell answer.

Part B I don't think is an iterative macro, I think it's a case of getting a calculator out.

 

 

Chris
Check out my collaboration with fellow ACE Joshua Burkhow at AlterTricks.com
jdunkerley79
16 - Nebula
16 - Nebula

Here's my solve - BaseA for 95% but needed some true integer maths for last part

Spoiler
jdunkerley79_0-1607852726548.png

All maths for part 2 - googling "simultaneous equations modular arithmetic" reminded me of the maths I had long since forgotten

But had to use Python tool to correct for inaccuracy in double arithmetic.

Will do a version with some Abacus functions

 

danilang
17 - Castor
17 - Castor

Here's my part A and part B, though only for the sample problem.  As @jdunkerley79 mentioned, Int64 operations are required for the full solution

 

w.png

Balders
10 - Fireball

I caved and am using python for part 2 because I don't have the brain power to create a modinv() function from scratch in Alteryx

cgoodman3
12 - Quasar
12 - Quasar

Part 2

 

Spoiler
So I found a tutorial which explained how to calculate the CRT and copied the logic in excel, then checked it with some of the examples given and it worked well.
replicated it in Alteryx and could get the examples working in Alteryx but couldn't get the final answer exactly as required.

Imagine it's something to do with the modulo function on very large numbers losing a bit of accuracy, so got the exact answer using https://www.dcode.fr/chinese-remainder (my answer is out by 198).

Then added a generate rows to go 300 numbers either side of the output generated by Alteryx and then use a modulo on the numbers to find the answer which matches.

The part 2 in Alteryx looks like this:

cgoodman3_1-1607874494805.png

 

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

When I need to use pen and paper I know I'm in trouble. What a brain melt! I did it baseA with an iterative, works with my input. Once the headache leaves, I'll try to read and see other people's solutions 😅

Spoiler
dsmdavid_0-1607874814344.png

and the macro

dsmdavid_1-1607874862133.png

 

 

A summary of my thought process:

Spoiler
I began with pen and paper, then some excel(highlighted = 54): dsmdavid_0-1607875473558.png

 

I started with
number 3, offset 0
number 5, offset 1
number 7, offset 2
number 11,offest 3

3&5 --> the first number that qualifies is 9 (mod(9,3) = 0 && mod(9+1,5)=0).
Then I need to find a number that qualifies for (3,5) and 7. I start with the first number that qualifies for the previous condition, go in increments of (3*5) --will all keep qualifying for mod(z,3) = 0, mod(z+1,5) = 0 -- until I find one that qualifies mod(z+2,7) = 0 (the first number that qualifies is 54)

For the next, I'll start at 54 and increase in increments of 105 (3*5*7) until I find one that qualifies mod(z+3,11) =0. (789).
And so on.

Balders
10 - Fireball

Alteryx workflow with a python tool when needed

 

Spoiler
For part 2 I used Chinese Remainder Therom as listed in here:
https://en.wikipedia.org/wiki/Modular_arithmetic

and grabbed a modinv() function from this stackoverflow page:
https://stackoverflow.com/questions/42049147/convert-list-to-pandas-dataframe-column

friends don't let friends reinvent the wheel 😅

Screenshot 2020-12-13 161720.png

 

Jean-Balteryx
14 - Magnetar

That part 2 really hurt my head. Discovered CRT after trying to find some relation between modulos and achieved to implement it in Alteryx but couldn't figure out the exact value. I guess it's due to accuracy problems, especially after @jdunkerley79 and @cgoodman3 replies. So used dcode tool to figure out the correct value. It's also on dcode that I studied and understood-ish the CRT.

 

Spoiler
Capture d’écran 2020-12-13 à 22.30.31.png
jdunkerley79
16 - Nebula
16 - Nebula

Awesome solve @dsmdavid 

 

My Abacus based solution is below. Needed to use it for 1 tool.

Spoiler
day13.jd.jpg
To correct the double maths issue. I converted the integers to strings and then used some new Abacus functions to compute as Int64

Int64Mod(
 Int64Add(
   iif([Row-1:Result]="","0",[Row-1:Result]),
   Int64Mult([Remainder],[ModInverse],[p])
 )
 , [Product]
)​