Ad
  • Default User Avatar

    That's actually a much better idea, and should really be trivial to add.
    You could even I think quite easily add statistics like speed percentile for the given language. That would make unusually slow solutions stand out and lead people to question why that might be.

    That being said, I don't think this site sees a lot of development so this might be a fool's hope :P

  • Default User Avatar

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

  • Default User Avatar

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

  • Default User Avatar

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

  • Default User Avatar

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

  • Default User Avatar

    Fwiw, I believe ToLowerInvariant should be preferred aswell, since ToLower is apparently slow for some reason. 6 years later, but still, maybe someone will read this ;)

  • Default User Avatar

    In case anyone is wondering the same: no, this is not a good solution. Pointlessly creating a range (plus the empty select which does nothing at all) when you could just for-loop over the numbers manually, simply to force the solution into a single line, is wasteful and inefficient.
    It looks slick but it does double the work that is needed (actually more since you don't really need to check every number from 1 to n, there is a sqrt(n) solution, but for what its trying to achieve this is a bad way of going about it. No offense to the authors intended!).

    Use Linq responsibly, kids!

  • Default User Avatar

    Exactly this. If you just sort both and then do the multiplications manually, you can quit early, whereas this could potentially do hundreds of thousands of unnescessary calculations even though the very first element might already be a dud. Linq is very suboptimal here.

    4 years later, but still somebody might find this useful :D

  • Default User Avatar

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

  • Default User Avatar

    Feels like the "Best Practices" button should be restricted or disabled entirely, since a whole bunch of people will upvote anything that's crammed into a neat one-liner as "Best Practices" even if it's horrendously inefficient.
    Not that my code is exactly brilliant, but from the comments on a lot of these I get the feeling that many people are learning terrible habits.

  • Default User Avatar

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

  • Default User Avatar

    It's been a minute, but if you're still interested, try looking up "method groups".
    They are essentially a way of telling the compiler: 'Hey, here's the name of a method with multiple overloads, please find the one with the correct signature for this scenario'.
    At least that is my probably flawed understanding.

  • Default User Avatar

    I could win a gold medal in the olympic 100m dash, but the other guys keep cheating by running faster than me. Life sure is cruel.