Ad
  • Default User Avatar

    Doing this with an array is a great way to understand the concept. In general though, LINQ is a very powerful tool for doing this kind of thing and building your own enumeration functions can help clean up your code in certain ways. It's very popular in the .NET world and you can generally expect to see it anywhere a collection type is involved.

    That being said, a general note: while I really enjoy this site, many of the code samples I've seen marked as "Best Practices" or "Clever" tend to be mainly just "Clever". Impenetrable stuff more often than not bubbles up to the top with high marks in "Best Practices", making me think that a lot of people are conflating "Best Practices" with "Shortest Code Possible". The former is often readable and understandable, the latter is often not.

    So if you see a solution for 1-5 kyu that's marked as "Best Practices", take it with a grain of salt. Typically 6-8 kyu solutions are short simply because they make use of things like LINQ. Readability and understandability are still the most important things 👍

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar