Faust wrote: ⤴Mon Nov 05, 2018 4:18 am
Yes , I was hoping for a lively discussion there , just as much as someone quickly coming up with the answer ,
or posing other similar riddles .... Oh Well
Well, if your hypothesis proves true then all who answered so far are terrible coders.
I don't think it's true though. Lateral thinking helps you find creative ways to solve problems, not necessarily write neat code. Take a code example from Mint's Update Manager:
https://github.com/linuxmint/mintupdate ... els.py#L47
Code: Select all
version_array = pkg_version.replace("-", ".").split(".")
versions = []
for element in version_array:
if len(element) == 1:
element = "00%s" % element
elif len(element) == 2:
element = "0%s" % element
versions.append(element)
How I would write it:
Code: Select all
versions = pkg_version.replace("-", ".").split(".")
for i, element in enumerate(versions):
versions[i] = (3 - len(element)) * "0" + element
Now I'd submit my approach would be much more neat, concise and efficient, but I don't think it's due to lateral thinking. There is nothing surprising about my approach, the original approach is just very step-by-step, lacking abstraction.