Ad
  • Default User Avatar

    I used almost the same approach, passed tests under Attempt button and was happy it's done.
    Yes, I thought about "what if first element will be default?"
    The answer depends on environment we work in:

    • If we're talking about real TDD production - I can say it counts as solution because tests passed. If tests were not designed to check this case - ask the guy who wrote these test. No need to fill code with garbage checks for everyting. If it will break somehow - we'll see an exception, fix tests, fix the code to pass tests. Happy end.
    • If we talk about unpredictable startup thing where you really don't know what to expect and have no tests - yes you all are right, we have to think about it.
  • Default User Avatar

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

  • Default User Avatar

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

  • Default User Avatar
  • Default User Avatar

    Wow I've done almost the same thing