Problem Statement | |||||||||||||
| Given a set of points, choose the maximal number of them that can be used to form a spiral.
A spiral is formed as follows: 1. Start at point (0, 0). 2. Draw a line segment from the current point to one of the given points (x, y). (x, y) is now the new current point. 3. Repeat step 2 as many times as possible while obeying the following rules:
These three spirals do not satisfy the first, second and third rules: These two do not satisfy the fourth rule: You are given a String[] points, each element of which represents a single point whose coordinates are given as "X Y" (quotes for clarity). Return the maximal number of points that can be used to form a single spiral. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
| - | points will contain between 1 and 15 elements, inclusive. | ||||||||||||
| - | Each element of points will be formatted as "X Y" (quotes for clarity), where X and Y are integers with no extra leading zeros. | ||||||||||||
| - | Each X and Y will be between -1000 and 1000, inclusive. | ||||||||||||
| - | All elements in points will be distinct. | ||||||||||||
| - | There will be no "0 0" in points. | ||||||||||||
Examples | |||||||||||||
| 0) | |||||||||||||
| |||||||||||||
| 1) | |||||||||||||
| |||||||||||||
| 2) | |||||||||||||
| |||||||||||||
| 3) | |||||||||||||
| |||||||||||||