Problem 44720. God of War: The Chains Of Olympus

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?


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

69.23% Correct | 30.77% Incorrect
Last Solution submitted on Dec 11, 2022

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers5

Suggested Problems

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!