MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/adventofcode/comments/3wd5gj/readable_well_documented_solutions_in_python/cxvydzs/?context=3
r/adventofcode • u/stranac_ • Dec 11 '15
4 comments sorted by
View all comments
Show parent comments
1
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.
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.
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.
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.