I though this would be a good challenge : http://adventofcode.com/2016/day/1
Given a sequence of rotations and distances following the pattern (L|R)[1-9][0-9]*, give the manhattan distance between the start and the ending points, that is the minimal number of vertical and horizontal moves on a grid.
For example, if we assume you started facing North:
Following R2, L3 leaves you 2 blocks East and 3 blocks North, or 5 blocks away. R2, R2, R2 leaves you 2 blocks due South of your starting position, which is 2 blocks away. R5, L5, R5, R3 leaves you 12 blocks away.
You can choose the separator between the moves (e.g. : "\n", ", ", or ","). You must give the answer as an integer in base 10.
Not a duplicate!
It is not a duplicate for multiple reasons :
- The moves are not the same. Here they are rotations, not directions.
- I want the Manhattan distance, not the euclidian.