Ad
  • Default User Avatar

    Seems like there's a bug in C#. My code passed the basic test, but fail the more advanced testing. I Console.WriteLine my result and it matches the expected results, but error message still reports a difference in index values
    .oooooo.
    ./.../.
    ......
    .../.
    ..
    .......

    See my results plus exptected.

    10010010
    10010010

  • Default User Avatar

    Great idea to group teams into Away and Home to simpify and shorten the algorithm.

  • Default User Avatar

    This code defines a Compare method that takes in two strings, line1 and line2, and compares them based on a predetermined order. The method returns a positive value if line2 should come before line1 in the order, a negative value if line1 should come before line2, and 0 if the two lines are equal.

    The method begins by defining an array of strings called order, which represents the order in which the lines should be sorted. The array includes strings such as "a ", "2 ", "3 ", etc., which represent different categories of lines that should be sorted in a specific order.

    Next, the method returns the difference between the indices of line2 and line1 in the order array. The indices are determined using the Array.IndexOf method, which returns the index of the first occurrence of a given value in an array. If either line1 or line2 is not found in the order array, the Array.IndexOf method returns -1.

    The [..2] syntax at the end of each line indicates that the comparison should be based on the first two characters of line1 and line2, respectively. This means that the method will compare the first two characters of each line and use the predetermined order to determine which line should come first.

    For example, if line1 is "a line" and line2 is "3 line", the method will return a positive value because "3 " comes before "a " in the order array. On the other hand, if line1 is "5 line" and line2 is "a line", the method will return a negative value because "a " comes before "5 " in the order array.

  • Default User Avatar

    I ended up spending over an hour trying to figure out the logic only to get a timeout after submiting the code. If you use Math you can solve this with one line of code.

  • Default User Avatar

    This is troublesome until you see the pattern (1, 11, 111, 1111) <== my hint to those who are struggling and getting hit with performance issues.

  • Default User Avatar

    Recommendation: if you use these strings @"" there's no need to escape Regex with double-slashes.

  • Default User Avatar

    Man, I just learned from your clever code: for (; maze[i, j] != 2; j = ++j % n, i = j > 0 ? i : ++i % n) ;

    Thank you for posting

  • Default User Avatar

    Wow, I particularly like this solution because the logic is spot on and I haven't seen this kind of approach before.

  • Default User Avatar
  • Default User Avatar

    This was one of the more interesting Katas and I really appreciated it.

  • Default User Avatar

    Clever, but you mutated the list.

  • Default User Avatar

    For sure...I was hoping there was a catch.

  • Default User Avatar
  • Default User Avatar

    Wow, I just learned from your code. Good stuff.

  • Default User Avatar

    My C# version fails a single random test because of a rounding issue - 54.47 vs 54.46
    I don't think this is worth spending time on, so I'm moving on:

    (failed test output below)
    Test Failed
    String lengths are both 331. Strings differ at index 330.
    Expected: "...0 Balance 720.28\nTotal expense 435.72\nAverage expense 54.47"
    But was: "...0 Balance 720.28\nTotal expense 435.72\nAverage expense 54.46"

  • Loading more items...