Ad
  • Custom User Avatar

    Imagine you go through a maze, UP, LEFT, DOWN, RIGHT would not be the same as standing still as you may be on the other side of the wall now for example.

    However if you'd go UP and then DOWN immediatly, you'd be in exactly the same spot, thus wasting effort.

    The problem is if you add walls and streets than going WEST or EAST after NORTH or SOUTH may open up different paths, so they don't cancel out.

    also as Chrono mentions, NORTH EAST is not the same as EAST NORTH, the path matters, maybe NORTH EAST is safe but EAST NORTH is not safe (maybe it crosses hostile territory or swamps or desert).

  • Custom User Avatar

    Read the instructions again, you only reduce opposite directions when they're next to each other (and it's being explained several times before). The task is not "find the minimal path" as you think it is.

    Additional it is a not sense that the solution [NORTH, EAST] can be valid, but the solution [EAST, NORTH] is not equivalent and so not valid

    While you reach the same point, the path is different.

  • Default User Avatar

    @MattZ306 you said that "you could simplify it because the opposite directions are next to each other" but the example given in the instructions is contradicting you

    For the path ["NORTH", "SOUTH", "SOUTH", "EAST", "WEST", "NORTH", "WEST"] in the example inside the instructions the solution is said to be ["WEST"]

    But if you can simplify only if opposite directions are next to each other the solution should be ["SOUTH", "NORTH", "WEST"] because the second SOUTH is not closer to the second NORTH

  • Default User Avatar

    There are problems on the solution paths.
    If the original path is [NORTH, WEST, SOUTH, EAST] the right minimal path is an empty array and not the array [NORTH, WEST, SOUTH, EAST]

    And if the original path is [SOUTH NORTH NORTH SOUTH EAST SOUTH WEST EAST SOUTH WEST] the minimal path is [SOUTH SOUTH] but I receive the error array lengths differed, expected.length=2 actual.length=4

    Additional it is a not sense that the solution [NORTH, EAST] can be valid, but the solution [EAST, NORTH] is not equivalent and so not valid