Problem Statement | |||||||||||||
A robot is moving in a plane following a set of instructions. The following instructions are possible (quotes for clarity only): "LEFT" - turn left 90 degrees "RIGHT" - turn right 90 degrees "TURN AROUND" - turn around (a 180 degree turn) "LEFT X" - turn left X degrees, where X is a positive integer "RIGHT X" - turn right X degrees, where X is a positive integer "HALT" - stop executing instructions; further instructions are not executed You are given a String[] containing the robot's instructions. Initially, the robot is facing north. Return the robot's final azimuth - the angle between north and the direction the robot is facing. Azimuth is always measured clockwise, and is a number between 0, inclusive, and 360, exclusive. For example, west corresponds to azimuth 270. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Notes | |||||||||||||
- | Turning right corresponds to turning clockwise, turning left corresponds to turning counterclockwise. | ||||||||||||
Constraints | |||||||||||||
- | instructions will contain between 1 and 50 elements, inclusive. | ||||||||||||
- | Each element of instructions will be a valid instruction, as listed in the problem statement. | ||||||||||||
- | In an instruction of the form "LEFT X" or "RIGHT X", X will be an integer between 1 and 179, inclusive, with no leading zeroes. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
| |||||||||||||
5) | |||||||||||||
|