Ad
  • Custom User Avatar

    @Jack-Hogerhuis: because it just creates an array while it is not necessary. The Reverse() method works on the string as well, no need to make it (copy it) to a char array first.

  • Custom User Avatar

    What I meant with my comment is just pure information: using O(N * logN) sorting is slower and that's it. Maybe I shouldn't have written "horrible".
    In most business applications where a code is not in hot path (read: inside of a tight loop), performance difference like this does not matter, and I never wrote it does.
    So my important point is that my comment never said a sorting solution is bad, I only sad it has worse performance and for many cases it is fine, but I wanted for people to be aware of this.

    To give another perspective for this: in katas on this site, business context are usually not mentioned, so we wouldn't know what constraints should we program to, so we wouldn't know if a solution would be running on a performance-critical system or just a hello world application, so both concise lazy solutions and high-performance solutions and ideas should be supported for the sake of learning.

    People basically downvoted my informative comment which is not lying and giving further information to the learner...

    By the way, thanks for quasi-proving my point.

  • Custom User Avatar

    Writing a reply since people greatly downvoted my comment.
    For those downvoting, I have a small note: compare the runtime performance of a modified minimum selection algorithm and the best sorting algorithm for this scenario...

  • Custom User Avatar

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

  • Custom User Avatar

    @jamescurran:
    I rephrased my comment to be simpler and more precise.

  • Custom User Avatar

    Indeed, but it is rarely needed to be able to handle real infinity.

  • Custom User Avatar

    The description says: "Create a simple calculator that given a string of operators (+ - * and /) and numbers separated by spaces returns the value of that expression"

    But C# test cases contain input without proper spacing.

    [TestCase("1-1", ExpectedResult = 0)]
    [TestCase("1+1", ExpectedResult = 2)]
    [TestCase("1 - 1", ExpectedResult = 0)]
    [TestCase("1* 1", ExpectedResult = 1)]
    [TestCase("1 /1", ExpectedResult = 1)]
    

    This is infuriating!

  • Custom User Avatar

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

  • Custom User Avatar

    Badly formatted, not very readable code, but clever and efficient.
    (The naming guideline for locals is camelCase, not snake_case.)

  • Custom User Avatar

    This solution (while it does the job) is inefficient, since sorting is unnecessary.
    A min-index searching algorithm is better fitting here which is O(N) compared to sorting which is at least O(N * log(N)).

  • Custom User Avatar

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

  • Custom User Avatar

    Discussion session is not about copy-pasting your own code, please do not do that next time!

  • Custom User Avatar

    Watch the other solution, this is not the best.

  • Custom User Avatar

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

  • Custom User Avatar

    Creative solution; however I feel an overkill to use a Queue for this simple task.
    My vote as "Clever" :-)

  • Loading more items...