General Discussions

Discuss any topics that are not product-specific here.

Advent of Code 2023 Day 20 (BaseA Style)

AlteryxCommunityTeam
Alteryx Community Team
Alteryx Community Team

Discussion thread for day 20 of the Advent of Code - https://adventofcode.com/2023/day/20

6 REPLIES 6
gawa
15 - Aurora
15 - Aurora

Finally, done. In last three days, I have been always thinking of D20 except for sleeping time(seriously).

I feel that D20 description is NOT easy to understand, and needed some assumption, to be honest. I'm writing what we need to understand to solve D20 in the below Spoiler.

For Part2, never try Brute Force, because it will just end up warming up your room temperature.

 

My WF

Spoiler
image.png

Part1

Spoiler
It's very important to understand the behavior of conjunction module correctly. You can understand one cycle as below

1) Receive pulses
One or more pulses  are coming to conjunction module.
image.png
2) Update memory
Memory status low/high is updated to the same to the received pulse type. Conjunction module doe NOT send pulse to downstream until all of memory state are updated.
image.png

3) Send Pulse
Based on the memory state in the above 2), conjunction module send pulses. The number of pulses sent is the same as number of pulses received. For example, if it receives 2 pulses, and at least one memory is LOW, then it sends out 2 HIGH pulses at one time(HIGH-HIGH). So, conjunction module sends the single type of pulses at one time (never sends mixed type; LOW-LOW-HIGH)
image.png

In short, there may exist multiple pulses between two module, looking like a que due to this behavior of conjunction module.
Loop the process until no modules sends pulses. That is one cycle of pressing one button.

Part2 

Spoiler
Part2 is, in a sense, not difficult if you carefully see how modules are combined. In my case, during the attempts on part1, I created Graph visualization for my study(appreciate Network Analysis tool in Predictive category, I love this tool😍)
(This is just visualization purpose, and this tool doe not directly create the answer, so I believe it is not violation to Base A)
image.png
You can see 4(four) big circles and, other nodes locating near center.
image.png
Part2 question says "rx" sends LOW pulses. Let's see where rx is in this diagram.
"rx" is final termination nodes(no output module), and it receives from a conjunction module "ql", that receives from 4 different conjunction modules "fz", "mf", "ss", and "fh".
So we can interpret this problem as "When module "ql" sends LOW to "rx"", that is further equivalent question to "When  4 modules "fz", "mf", "ss", and "fh" send HIGH pulses at the same time?"
image.png
By modifying the WF of part1, get data of how many pressing buttons are needed to "ql" receives HIGH pulse from those 4 modules. In my dataset, no records appeared even after 1,000 press. So I run it again until 10,000 press, and finally got 8 records of HIGH pulses to "ql", 2record for each 4 senders in different timing. After that...please look carefully the result. You already have answer in your hand.
Spoiler
One module sends HIGH pulse to "ql" in a certain cycle. Just multiplying the cycle number of those 4 modules, it will be the answer. LCM trick again.

 

AndrewDMerrill
13 - Pulsar

The idea of high pulses and low pulses immediately brought to mind computers and binary signals especially with Flip Flops and Conjunction modules that function like N-AND gates. @gawa has done a good job explaining the structure of the problem although, I would like to correct a couple things to hopefully not over complicate things for those who are attempting this problem. Every high/low pulse can be thought of as a singular entity that populates a queue, where each pulse will be evaluated one at a time in the order that they entered the queue. This means that the case @gawa included in his diagram for the conjunction module, where multiple signals enter the module at once will never occur, this is also true for the Flip Flop Modules. You do not need to think through or build a workflow that handles multiple synchronized inputs for any module because that will not happen. Just focus on one input at a time (it is actually the case that you will never even have two neighboring signals in the queue going to the same module):

Queue PositionInstruction
1Low to %A
2High to %A
3High to &B

 

^The example above will never occur in solving this problem (if it does, something is wrong) because Position 1 and 2 both have signals going to %A, one immediately after the other. The following example is something you could see:

Queue PositionInstruction
1Low to %A
2High to &B
3High to %A

 

Here is the structure/function of the Conjunction Module:

Spoiler
Conjunction.png

Hint for Part 2:

Spoiler
The graph @gawa included looks great is the perfect representation to conceptualize what's going on. When I was working on solving this problem, I drew a similar picture:
Part 2 Graph.png
If you work through this chart, you'll notice something very interesting:
SUPER SPOILER
Spoiler
The inverters can only change when they receive a low signal, and high signals are blocked and stop propagation. This means that every button press, %A in the image above will Flip, but %B will only Flip every other button press, which occurs when %A goes from on to off. Continuing this trend: %C flips every 4, %D every 8, %E every 16, etc.

This ring forms a binary system, and since &X will only output a low signal when all inputs are high signals, this will occur in the example above when %A, %B, %G, %I, %J, %K, and %L have output a high signal (%A's input is what will actually trigger the Low signal output from &X).

Super interesting fact is that the frequency that this occurs at is the binary representation of the inputs to &X starting with %A in the position of 2^0 (Where input is 1 and output is 0 from &X). The above example is:
111101000011 = 3907

Do this for each ring, find the LCM of each of these and you will have your answer!

Workflow:

Spoiler
Main:
_Main.png
Iterative Macro (Part 1):
_Iterative.png
^ I enjoyed putting this macro together since it keeps track of everything: all the modules, the memory registers, and the signals being sent.

I have included my LCM macro.

 

Happy Solving!!!

Pang_Hee_Choy
12 - Quasar

I built python code first, and refer to reddit as well.

then convert to alteryx.

 

have to say that when change 1 or 2 lines/ variable. alteryx take much extra time to do it. 

 

python less then 1 minute for both parts.

my alteryx workflow is take 7mins~ for part1 and 30mins~ for part2.

 

this time taken is hard to analysis or change...

Spoiler
Part1:
1. split the iteration data to 2 parts, i.e. data and process.
(want to raise idea to handle variable, like simple low count and high count for this case)
2. then process 1-by-1 each, (that why my time speed is high)

note: ensure the sorting in union, new process should in the bottom.Screenshot 2023-12-27 131507.png

 

Screenshot 2023-12-27 132139.png

Part2: Due to I already got answer in python. hence, I limit the flow to press button for 4000, to reduce time spent.

 

AkimasaKajitani
17 - Castor
17 - Castor

This is needed the most complex logic in this year's AoC. I made the iterative macro and dispose it many times .I am seriously wondering why there are NOT multiple repetitive inputs and outputs in Alteryx Iterative macro.

 

Viz by Network analysis tool

 

Spoiler
Blue : flipflop
Yellow : Conjection
Red : button for stupid elf and broadcast module
AoC_2023_20_02.png
The cause of my worries for part 2 : 

AoC_2023_20_03.png

 

 

Spoiler
Part 1 : I only carefully made the workflow. But it really difficult. So I thought why it is difficult. My opinion is that it is difficult how do we hold the data. In other words, if we can use multi iterative input and output, I don't think it is too difficult. But we can't do it, so I forcibly unioned them.

I wanted to use the data below repeatedly.

Pulse :
AoC_2023_20_04.png

Device status( flip flop status) :
AoC_2023_20_05.png
  
Memory for conjection

AoC_2023_20_06.png

So I unioned as follows.
AoC_2023_20_07.png


On each repeat, I filtered them ans used them.


The macro to push the button. There are many macro output tools for debug. 
AoC_2023_20_10.png

This is outer macro for pusing 1000 times.

AoC_2023_20_09.png


Workflow for part 1
AoC_2023_20_11.png


Part 2: I needed the pulse pattern which is connected to rx module. After getting the pattern, we can use LCM. As a result, I pushed the button 5000 times and finally got the pattern.

Final workflow:

AoC_2023_20_08.png

 

mmontgomery
11 - Bolide

I spent a few days before the holidays trying to do this and picked it back up today. Logic in spoiler

Spoiler
My focus was to break this into as many discrete procedural steps as possible
P1:
1. I created two .yxdbs for inputs to update over time (one for flip flop modules and one for conjunctions)
2. I built out the iterative base macro to account for each possible step while forcing order one step at a time. I'm looping on the state (current module, signal, next module and order) while updating the .yxdbs and outputting the signal on each step to a macro output
3. The iterative macro has three categories to set up the logic flow: button, broadcaster, and non-button/broadcaster.
4. I took the base iterative macro and put it in another iterative macro to count the various steps
5. I put the nested macro in the main workflow and ran it.

P2:
1. I ran it 10k times and then found out the feeding modules once they hit high. Then I did LCM to solve itD20P1_Macro3.pngD20P2.pngD20P1_Imacro.pngD20P1.png

 

Tokimatsu
12 - Quasar

I don't want to see this anymore...

Spoiler
スクリーンショット 2024-01-07 182404.png
スクリーンショット 2024-01-07 182534.png

Labels