Advent of Code 2020 - BaseA Style (Day 13)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Discussion thread for day 13 of the Advent of Code : https://adventofcode.com/2020/day/13
- Labels:
- Advent of Code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
Check out my collaboration with fellow ACE Joshua Burkhow at AlterTricks.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Here's my solve - BaseA for 95% but needed some true integer maths for last part
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Part 2
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:
Check out my collaboration with fellow ACE Joshua Burkhow at AlterTricks.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Alteryx workflow with a python tool when needed
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 😅
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Awesome solve @dsmdavid
My Abacus based solution is below. Needed to use it for 1 tool.
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]
)
