Ad
  • Default User Avatar

    You are one of the few who really checks whether the acceptance criteria are met, namely a maximum of 10 numbers and that each number is in the range from 0 to 9. Your code, like mine probably, may not look that cool single-line, but in practice it would survive any unit test. The 2 discounter tests of codewars are not to be taken seriously. The favored solution is wrong in my opinion, because there is no check of the input. Such a thing is in practice deadly. Therefore I find your solution very good.

  • Default User Avatar

    Acceptance-Criteria: Write a function that accepts an array of 10 integers (between 0 and 9), that returns a string of those numbers in the form of a phone number.

    int[] elementsWrong = new int[] { 23, 9, 7 };
    var resWrong = CreatePhoneNumber2(elementsWrong);

    Would return: resWrong = (000) 000-2397

    In the acceptance-criteria is the word "accepts". So i have to check, if the array is 1. 10 digits and 2. every digit is between 0 and 9. In other words:
    If I have to fetch at least 10 beers from the gas station, which may cost between 0 and 9 Euros, then I would arrive with this solution above with 3 beers, one of which even costs 23 Euros.