In-depth analysis of Python solutions to Advent of Code day 1

In-depth analysis of Python solutions to Advent of Code day 1

8 comments · 87% upvoted · source · other discussions

comments

ASIC_SP

That's a very in-depth article!

I really should spend some time using the various features of itertools module.

RojerGS [OP]

itertools is just awesome :)

Jolteon0

The double iterator loop is pretty awesome.

RojerGS [OP]

Which one are you talking about?

Jolteon0

for prev_, next_ in zip(prev_it, next_it)

RojerGS [OP]

Ah yes, that's an interesting one :)

Surkov__

Great article, but I do wonder. I used a simple for loop with a lastVal-Variable which gets overridden each loop. Would this be considered an anti-pattern? Seemed like the most simple/readable solution and no need to mess with indices.

For the second part I used pandas rolling sum, a somewhat lazy solution.

RojerGS [OP]

I don't think that's an anti-pattern. I'm just personally not a fan of doing too much bookkeeping with my variables :p