Ad
  • Default User Avatar

    "Invalid user type. Must be one of: " + string.Join(", ", validUserTypes) is a code repetition.
    the second won t be used exceptafter a bad evolution with adding a new type that is not considered in switch. So the second error would rather be a not implemented exception.

  • Custom User Avatar

    Not best practice. This can be done with time O(n) and space O(n) using a dictionary.

    This is very slow since it is using two for loops making it at worst O(n^2).

  • Custom User Avatar

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

  • Custom User Avatar

    As a starter, try to use Markdown when asking a question as it is very difficult to read what you posted in its current form.

  • Custom User Avatar

    What is the reason for using \z and not $?

    Does it catch any edge cases?

  • Custom User Avatar

    Have a look at the problem description again. It says that you will be given an array of numbers that you are supposed to convert to a phone number in the format that the example show you.

    Kata.CreatePhoneNumber(new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}) // => returns "(123) 456-7890" <----- **this!**
    

    Also, remember that you do not need to convert numbers to strings as this is done implicitly (if you are using c#, which it looks like you do).

  • Custom User Avatar

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

  • Custom User Avatar

    I experienced the same, and while the test case message is STILL(!) incorrect, the issue is not with the test case, but rather just an incorrect solution.

  • Custom User Avatar

    Interesting. My Console.WriteLine must be behaving strangely in the codewars IDE. Thanks for the help.

  • Default User Avatar

    It looks like you're mixing several test cases together. The input for the test you fail is just a, and the filter token for that test is also a. Your solution is returning a, but it expects an empty string.

  • Custom User Avatar

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