@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
Think of NORTH, SOUTH, WEST, EAST as chemical products. When NORTH and SOUTH or WEST and EAST are side by side they annihilate each other; they don't if they are separated by another element.
I quote a post by @Unnamed (see below in the Discourses):
Only adjacent directions should be reduced. It's like considering curvature of the Earth. Or maybe going down a spiral staircase where you end up in a different layer.
Nobody told you that you are on a "Cartesian Plane".
The problem statement only wants you to cancel out opposite directions when they are adjacent in the list. It is true that the path "North East South West" ends up at the beginning, but since the "South" direction is not directly next to the "North" direction, the problem wants you to ignore it. If the path was "North South East West", you could simplify it because the opposite directions are next to each other.
Alr raised above
Read what dulot wrote up there.
Better variable names than f. Otherwise good idea.
@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
Kind of Puzzle Bobble ;)
Think of NORTH, SOUTH, WEST, EAST as chemical products. When NORTH and SOUTH or WEST and EAST are side by side they annihilate each other; they don't if they are separated by another element.
I quote a post by @Unnamed (see below in the Discourses):
Nobody told you that you are on a "Cartesian Plane".
Hey, CSDUMMI.
The problem statement only wants you to cancel out opposite directions when they are adjacent in the list. It is true that the path "North East South West" ends up at the beginning, but since the "South" direction is not directly next to the "North" direction, the problem wants you to ignore it. If the path was "North South East West", you could simplify it because the opposite directions are next to each other.
Hope that helps explain it a little bit better :)
Sorry, but the rules contradict themself.
Don't overthink it, just follow the instructions, even if you don't agree with them.
That makes no sense in any (Euclidian) Coordinate System.
This comment is hidden because it contains spoiler information about the solution
Could someone please add a sample test in Haskell?
Or how could I do that?
Don't forget to mention it's in Haskell.
You don't really need the Data.Char imported.
Loading more items...