The Spartan warrior, Kratos, is held by a chain of n > 1 links in the underworld. His only chance of survival is to break the chain by removing the minimum number of single link, so that it would be possible to create a chain of any integer length between 1 and n links, inclusive, from the resulting pieces. He only has enough stamina to remove the minimum number of single links. Anything more, and he forever remains doomed in the underworld.
At what points should he break chain to free himself and continue his vengeance journey to Olympus?
ILLUSTRATION:
n = 3 link chain can be broken, such that the resulting pieces can combine to give a chain of any integer length between 1 and n links, inclusive, by removing a minimum of a single link in any of the following way:
Segments Breakpoints O- O-O [1] O -O- O [2] O-O -O [3]
You are to return only one of these possible breakpoints i.e. either 1, 2, or 3 will be accepted as a correct solution for n = 3.
Similarly, n = 8 link chain can only be broken by removing a minimum of two single link as shown:
Segments Breakpoints
O- O-O -O- O-O-O-O [1,4]
O- O-O-O-O -O- O-O-O [1,5]
O- O-O-O-O -O- O-O [1,6]
O -O- O -O- O-O-O-O [2,4]
O -O- O-O- -O- O-O-O [2,5]
O -O- O-O-O -O- O-O [2,6]
O -O- O-O-O-O -O- O [2,7]
O-O -O- -O- O-O-O-O [3,4]
O-O -O- O -O- O-O-O [3,5]
O-O -O- O-O -O- O-O [3,6]
O-O -O- O-O-O -O- O [3,7]
O-O -O- O-O-O-O -O [3,8]
O-O-O -O- -O- O-O-O [4,5]
O-O-O -O- O -O- O-O [4,6]
O-O-O -O- O-O -O- O [4,7]
O-O-O -O- O-O-O -O [4,8]
O-O-O-O -O- -O- O-O [5,6]
O-O-O-O -O- O -O- O [5,7]
O-O-O-O -O- O-O -O [5,8]
Maximum running product for a string of numbers
833 Solvers
Find common elements in matrix rows
829 Solvers
Change a specific color in an image
42 Solvers
35 Solvers
Detect a number and replace with two NaN's
158 Solvers
Problem Tags