Took too long cause of tedious bugs/minor mistakes, but, got P1.
This challenge would be much easier with a more flexible object than a dataframe (tabular rows/columns). It took me a long time and multiple attempts to arrange my data to even start the calculations.
Finally, it is done. It took too much time for P2.
Part 1: I only simulate the rock and jet.
Part 2: Of course I can't fall a trillion blocks!! So, I falled 6000 blocks to find the pattern. I took some sample(100 samples) which should contain the rock pattern and the height diff from previous height and match it from the 6000 blocks results in Matching macro. In my case, after falling the 2439 blocks the diff of the height pattern is repeated each 1700 blocks.
I didn't try to shoten the workflow running time, but I once found the pattern, so I can optimize the workflow to shorten the running time.
Part 1 TETRIS macro : only simulate the rock and jet.
Took awhile to solve part 2, and I generated way too many records to make sure I captured the pattern. I also spent some time optimizing my macro only to realize that it took the exact same amount of time...
duplicate reddit python, take few hours to understand it.
link: adventofcode/17b.py at main · tmo1/adventofcode · GitHub
2. adjust all y by minus the lowest value (now the pattern is standard to compare)
3. compare x1-x7 + type + jetID, remain any have same pattern (pick 1, it have alot)
4. calculate the cycle of rock and Y, and adjust the value near to 1 trillion.
5. fill in the variance to 1 trillion rocks. (continue the step based on jetID until rocks is fulfil.)
a. get the jetID, and use it as start point (data from part1),
b. add variance to rock get from a
c. get new jetID and use it as stop point.
d. get different Y between a and c.
e. add it to 4.
Welll this took WAY longer than expected - this is just part 1.
Turned out that I'd made a few simple mistakes - and found them eventually by going back to the info provided on part 1 - and breaking down EVERY SINGLE move into test cases, and comparing them to mine. The problem turned out to be using base 0 numbering, but getting the mod wrong....
I've not done a big writeup here - will do this once I finish part 2
I feel you @mmontgomery - same here!
OK - after getting done with Part 1 - part 2 came quickly.
Notes within