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]
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers5
Suggested Problems
-
4562 Solvers
-
Is my wife right? Now with even more wrong husband
1340 Solvers
-
23656 Solvers
-
Find perfect placement of non-rotating dominoes (easier)
381 Solvers
-
How long is the longest prime diagonal?
409 Solvers
More from this Author18
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!