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]
Project Euler: Problem 5, Smallest multiple
254 Solvers
66 Solvers
28 Solvers
Return elements unique to either input
487 Solvers
645 Solvers
Problem Tags