Don't forget to register for our panel discussion with Dean Stoecker, Amy Holland, and Mark Frisch occurring next Wednesday, June 1!

2022-05-26 Updates: Email: If you're not seeing emails be delivered from the Community, please check your spam and mark the Community emails as not junk. Thank you for your patience.
alteryx Community

# General Discussions

Discuss any topics that are not product-specific here.

## Advent of Code 2020 - BaseA Style (Day 13)

16 - Nebula

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

13 REPLIES 13
13 - Pulsar

Here's my Part A.

Spoiler

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
ACE Emeritus

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

Spoiler

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

18 - Pollux

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

11 - Bolide

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

13 - Pulsar

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:

Chris
Check out my collaboration with fellow ACE Joshua Burkhow at AlterTricks.com
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

and the macro

A summary of my thought process:

Spoiler
I began with pen and paper, then some excel(highlighted = 54):

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.

11 - Bolide

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 😅

16 - Nebula

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
ACE Emeritus

Awesome solve @dsmdavid

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

Spoiler

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

``````Int64Mod(