I would like to know if there is an anlgorithm that could help me solve the following example problem.
First of we have a list of 1 and 0 :
011001010111 of length 12.
Then we have an x number of 1 to inject anywhere in the list, for instance x=3(not necessary to inject all 3).
Lastly we have a number y that checks the list for every y-th element for a 1.
For instance y=4 which means the program in this example before injections will output 2 as 4th element contains a 0 but both 8th and 12th contain a 1.
The Algorith in this example should inject a maximum of 3 1s into the list so that every 4th element would contain as fewer 1 as possible.
A correct answer for this example could look something like this:
(Injecting into list with first index being 1)
1. Injection at index 7 => list=0110011010111, length=13, output=1.
2. Injection at index 10 => list=01100110110111, length=14, output=1.
3. Injection at index 10 => list=011001101110111, length=15, output=0.
Another correct asnwer can also look like this:
1. Injection at index 1 => list=1011001010111, length=13, output=2.
2. Injection at index 1 => list=11011001010111, length=14, output=3.
3. Injection at index 1 => list=111011001010111, length=15, output=0.
Lenght=<10000, x=<50, y=<10000
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)