Ad
  • Custom User Avatar

    I guess append() would create a new slice each time it cannot fit the numbers anymore, so it might be inefficient compared to creating a slice the size of n int in the first place. Although the code is really clean and short, I liked that.
    UPD: Oh! And a slice created like that will address the underlying values of that array, you should use predefined copy() function.

  • Custom User Avatar

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

  • Custom User Avatar

    I wanted to solve in the same way, but i wondered whether the code should check for the necessity to return NO in every iteration of the switch-case cycle. The reasoning is that with this code above (if I get it right) at a certain moment while the queue goes on we might not have the change, and let's say the variable twentyFives first becomes a negative, but then becomes positive again, which allows us to pass the final test in the body of the "if" statement. I will try to illustrate:
    the order of bills is 25, 25, 100, 25, 25. The value of the "twentyFives" variable will change the following way: 1, 2, -1, 0, 1. We pass the final test, but in reality we cannot give the change to the guy with a 100 bill and therefore we did not serve every client in the line.

  • Custom User Avatar

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

  • Custom User Avatar

    Could somebody please explain, why don't we have to convert the string to Object type, whereas it is a necessity when we return false in this Kata? I guess it's because the Object type is a class-generated type (not an object type as such, the one that begins with lowercase), but i can't think this through any further.

  • Custom User Avatar

    I like this one more than others in terms of being less obvious

  • Custom User Avatar

    It would be more readable if you used the "$" sign before each string you return, it would not be so colorful this way. Otherwise it is just the same as mine, except for the initialized int at the end of the code.