Ad
  • Custom User Avatar

    @RyanGPalmer. Yep. You got it - it was example of:

    Sometimes a line may be valid in one direction but not the other. Such a line is still considered valid.

    See other discourse comments here. I think other people struggled with exactly same example.

  • Custom User Avatar

    @dinglemouse I understand what you are saying but some of the examples seem to contradict this. For example:

       +-------+
       |      +++---+
    X--+      +-+   X
    

    How does this not count as ambiguous? There is a very obvious junction where you could turn either left or right. However, if you turn left, you get to a dead end. So if it's only considered "ambiguous" when both paths could possibly reach the end, then that contradicts this example:

        +-+    
        | |    
        ++++   
        ++++   
       X+++    
         +---X
    

    There is no junction here where both of the two directions are valid. Thus I'm afraid I just do not understand what meets your definition of ambiguity. (By the way my code passes every test except the latter example, so perhaps its possible we can discuss that, since I have been staring for awhile and do not understand how it could be considered ambiguous. There's only one possible path backwards or forwards.)

    EDIT:

    Nevermind, I understand now. The first example is certainly ambiguous from one direction, but from the other direction there is no ambiguity. Thus it fits your description where paths could potentially be valid from one direction and not the other.

  • Custom User Avatar

    I'm passing 23 out of 24 tests, but failing on this one:

        +-+
        | |
        ++++
        ++++
       X+++
         +---X
    

    It's supposed to be invalid but I do not understand how this is invalid. Seems perfectly valid to me and my code agrees.

    EDIT:

    I understand it now, this is not valid because there are places where you could turn left or right. I had an incorrect understanding of one of the examples which lead me to a false assumption about what was considered ambiguous.

  • Custom User Avatar

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

  • Custom User Avatar

    According to the CW wiki, "Best Practices" are solutions that you would expect to see in production code. Maintainability and readability are favored over performance and elegance. Of course, in the real world, production code standards will vary. Regardless, this solution reads well, and would be easy to manage due to the granularity.

  • Custom User Avatar

    As others have stated, please indicate the sequence must also be a set. Description is incomplete without this detail.

  • Custom User Avatar

    By definition, a sequence can have repeated elements. Thus, the description of this Kata is insufficient. The best solution for a traditional sequence is to use a PriorityQueue. However, since the sequence must also be a set, a SortedSet implementation is required.