ALTERYX INSPIRE | Join us this May for for a multi-day virtual analytics + data science experience like no other! Register Now
The Alteryx Community will be temporarily unavailable for a time due to scheduled maintenance on Thursday, April 22nd. Please plan accordingly.

General Discussions

Discuss a wide range of topics! Questions about the Alteryx Platform should be directed to the appropriate Product discussion forum.

Advent of Code 2020 - BaseA Style (Day 23)

14 - Magnetar

Discussion thread for day 23 of the Advent of Code :

16 - Nebula
16 - Nebula

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)




17 - Castor
17 - Castor

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.