General Discussions

Discuss any topics that are not product-specific here.

Advent of Code 2020 - BaseA Style (Day 23)

16 - Nebula
16 - Nebula

Discussion thread for day 23 of the Advent of Code :

ACE Emeritus
ACE Emeritus

Not sure I have a clue how to do part 2 resorted to Python (the data structure needed is too hard in BaseA!)


Went for iterative macro for 1

Part 2 Python:

from ayx import Alteryx
import pandas as pd 
df ="#1")
vals = list(df['V'])
l = len(vals)

class Cup:
    def __init__(self, v: int):
        self.v = v = None
    def __repr__(self):
        return f'C({self.v}:{})'

d = {}
for i, v in enumerate(vals):
    c = Cup(v)
    if i > 0:
        d[vals[i - 1]].next = c
    d[v] = c
d[vals[-1]].next = d[vals[0]]

current = d[vals[0]]

for i in range(df['games'][0]):
    c_next = =
    pickup = [c_next.v,,]

    i = 1
    while (current.v - i if current.v - i > 0 else current.v - i + l) in pickup:
        i += 1
    i = (current.v - i if current.v - i > 0 else current.v - i + l)
    t_next = d[i].next
    d[i].next = c_next = t_next
    current =

current = d[1]
output = []
while ( != 1):
    current =

df = pd.DataFrame(output)




18 - Pollux
18 - Pollux

Part I as an iterative macro.  A single multirow would be massive because of the requirement to find the largest value smaller than the current one.  A large nested iif could do it with something on the range of 25 clauses comparing the 5 remaining values to each other.  This monster would be nested inside the outer part that rearranges the string.  Too... many... parentheses...


Part II hits the temporal limits of what can be done in BaseA.  Without arrays, there's no way to conveniently store 1M values other than in rows.  While it is possible to convert this algorithm from string based to row based and using filters and sorting to rearrange the items as required, iterating 10M times is not something that I'm prepared to wait for.