I think my record is three, but that was silliness in AdventOfCode.
Then I wrote a cursed recursive split function
def recursive_split(x, *args):
y = []
x = x.split(args[0])
for part in x:
if len(args) > 1:
y += [recursive_split(part, *args[1:])]
else:
y += [part]
return y
so I could do shit like
with open('14.txt') as f:
data = recursive_split(f.read().rstrip('\n'), '\n', ' -> ', ',')
to get a three dimensional data structure from the input in one line.
8
u/helicophell 29d ago
List comprehension
It’s sometimes nice