Discussion thread for day 13 of the Advent of Code : https://adventofcode.com/2020/day/13
Here's my Part A.
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.
Here's my solve - BaseA for 95% but needed some true integer maths for last part
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
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
Part 2
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 😅
and the macro
A summary of my thought process:
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.
Alteryx workflow with a python tool when needed
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.
Awesome solve @dsmdavid
My Abacus based solution is below. Needed to use it for 1 tool.
Int64Mod(
Int64Add(
iif([Row-1:Result]="","0",[Row-1:Result]),
Int64Mult([Remainder],[ModInverse],[p])
)
, [Product]
)