Problem Statement
You are given the
Let "theta" be the angle of the turn rounded to the nearest integer degree (turn angles exactly between two integers will not be allowed, see constraints).
- If theta < 10, no turn is required, return "CONTINUE".
- If 170 <=; theta, return "U-TURN".
- If 10 <= theta < 60, return "TURN SLIGHT <dir>:theta"
- If 60 <= theta < 120, return "TURN <dir>:theta"
- If 120 <= theta < 170, return "TURN SHARP <dir>:theta"

The above diagram shows the basic algorithm for determining the turn angle. Notice that turn can be executed by turning right with angle A or left with angle (360 - A). For this problem, always choose the smaller turn. The diagram only shows the case where t1 - t2 is the smaller turn. This convenience is not always the case.
The points will be of the form: <x>:<y> and x and y are perpendicular, equal-length units (unlike latitude and longitude, which are not equal-length units on most parts of Earth). In other words, x and y are standard Cartesian coordinates.
For example, "5:3" or "11:-7"
Note that moving from 0:0 to 0:3 to 3:3 requires a 90 degree RIGHT turn.
The return value must be of the form: <TURN <direction>:<angle> or "CONTINUE" or "U-TURN"
For example, "TURN RIGHT:90" or "TURN SLIGHT LEFT:170"
Definition
- Class:
- TurnFinder
- Method:
- turnAngle
- Parameters:
- String, String, String
- Returns:
- String
- Method signature:
- String turnAngle(String p1, String p2, String p3)
- (be sure your method is public)
Notes
- The shorter turn out of left and right will always be the one with the angle less than 180.
- The first and third point may be equal (p1 == p3).
Constraints
- No leading zeros will be allowed for the coordinates.
- No two consecutive points may be equal (p1 != p2, p2 != p3).
- The points will be of the form:
: where x and y are integers between -100 and 100 inclusive with no leading zeros. - Some inputs will not be allowed because it can cause hardware-dependent rounding errors. Inputs where the turn is within 0.01 degrees of rounding ambiguity will not be allowed.
Examples
"0:0"
"0:3"
"3:3"
Returns: "TURN RIGHT:90"
"47:32"
"20:80"
"-5:0"
Returns: "TURN SHARP LEFT:133"
"0:0"
"20:20"
"50:50"
Returns: "CONTINUE"
"0:0"
"50:50"
"0:0"
Returns: "U-TURN"
"50:50"
"30:30"
"20:-5"
Returns: "TURN SLIGHT LEFT:29"
"0:0"
"0:10"
"-19:9"
Returns: "TURN LEFT:93"
"0:0"
"0:10"
"1:6"
Returns: "TURN SHARP RIGHT:166"
"85:-71"
"-56:57"
"-10:-65"
Returns: "TURN SHARP LEFT:153"
"0:0"
"-10:0"
"-10:-1"
Returns: "TURN LEFT:90"
"0:0"
"0:-1"
"-10:-1"
Returns: "TURN RIGHT:90"
"-100:0"
"100:0"
"-100:1"
Returns: "U-TURN"
"0:0"
"1:7"
"2:-8"
Returns: "TURN SHARP RIGHT:168"
"0:0"
"-3:-3"
"5:5"
Returns: "U-TURN"
"0:0"
"-100:-100"
"-100:100"
Returns: "TURN SHARP RIGHT:135"
"0:0"
"30:40"
"60:80"
Returns: "CONTINUE"
"3:0"
"0:4"
"0:0"
Returns: "TURN SHARP LEFT:143"
"40:-30"
"-20:2"
"-18:10"
Returns: "TURN RIGHT:76"
"-50:0"
"-50:50"
"-41:100"
Returns: "TURN SLIGHT RIGHT:10"
"0:0"
"0:1"
"-10:11"
Returns: "TURN SLIGHT LEFT:45"
"0:0"
"0:1"
"-40:24"
Returns: "TURN LEFT:60"
"5:5"
"3:0"
"-20:29"
Returns: "TURN SHARP RIGHT:120"
"0:0"
"1:15"
"5:22"
Returns: "TURN SLIGHT RIGHT:26"
"-5:20"
"30:-2"
"-10:-10"
Returns: "TURN SHARP RIGHT:137"
"0:1"
"0:0"
"1:0"
Returns: "TURN LEFT:90"
"0:0"
"1:15"
"5:22"
Returns: "TURN SLIGHT RIGHT:26"
"-5:20"
"30:-2"
"-10:-10"
Returns: "TURN SHARP RIGHT:137"
"0:1"
"0:0"
"1:0"
Returns: "TURN LEFT:90"