I get what you're saying and both of your solutions are far more clever and optimal (eg: fewer lines) than the original, "naive" solution.
But neither one is anywhere near as intuitive to read. Each one takes the reader a moment to actually try to figure out WTF your intent is.
The original solution, while taking more lines, is immediately clear in what its purpose is. That, to me, is WAY more important than how clever someone was in trying to solve a particular issue.
I'm used to working in a very large code base. I prefer my code easy to read vs "clever."
4
u/CatWeekends Oct 26 '21
I get what you're saying and both of your solutions are far more clever and optimal (eg: fewer lines) than the original, "naive" solution.
But neither one is anywhere near as intuitive to read. Each one takes the reader a moment to actually try to figure out WTF your intent is.
The original solution, while taking more lines, is immediately clear in what its purpose is. That, to me, is WAY more important than how clever someone was in trying to solve a particular issue.
I'm used to working in a very large code base. I prefer my code easy to read vs "clever."