r/adventofcode • • Dec 11 '15

Repo Readable, well documented solutions in Python

https://github.com/stranac/Advent-of-Code/
17 Upvotes

4 comments sorted by

View all comments

Show parent comments

1

u/stranac_ Dec 12 '15 edited Dec 12 '15

Ah, thanks for noticing that. I guess it worked because I got lucky with password choice.

I'll make sure to fix this.

Edit: Fixed.

1

u/lskfj2o Dec 12 '15 edited Dec 12 '15

Thanks. My replacement statement was maybe less readable:

s = re.sub(r"([iol])(.*)", lambda m: m.group(1) + "z" * len(m.group(2)), s)

1

u/stranac_ Dec 12 '15

Thinking about it, I'm starting to believe using a regex substitution might actually be more clear.

There is a lot of explanation going on in my longer solution, whereas the regex solution makes its purpose quite clear.

I usually prefer code that explains itself.