We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I would only offer one alternative.
Instead of
pattern[::-1]
consider
list(reversed(pattern))
Yes it is more verbose, but the intent is clearer. Particularly for developers who have to refactor (or at least understand) that code who also have to work in many languages and don't always catch nuances of each one.
In data science, particular at companies that favor open source or very large companies with many "standard" products, a data scientist could be using a half dozen languages or more, so in that case "obvious" wins over "specialty".
That being said, I usually prefer shorter code, so I can easily appreciate arguments for staying with [::-1].
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Designer Door Mat
You are viewing a single comment's thread. Return to all comments →
I would only offer one alternative. Instead of pattern[::-1] consider list(reversed(pattern))
Yes it is more verbose, but the intent is clearer. Particularly for developers who have to refactor (or at least understand) that code who also have to work in many languages and don't always catch nuances of each one.
In data science, particular at companies that favor open source or very large companies with many "standard" products, a data scientist could be using a half dozen languages or more, so in that case "obvious" wins over "specialty".
That being said, I usually prefer shorter code, so I can easily appreciate arguments for staying with [::-1].