Introduction
I want to find the substring with the most 1
's in a sequence of 0
's and 1
's.
Input
Your program has two inputs, the sequence and the substring length.
The sequence is any number of 0
's and 1
's:
01001010101101111011101001010100010101101010101010101101101010010110110110
The substring length is any positive non-zero integer:
5
Output
Your program should output the starting index of the first substring of the given length that contains the most 1
's. With the above input, the output is:
10
The first character in the string starts at an index of 0
.
Scoring
Shortest code wins!
Rules
- Your program must always output the correct index for any valid inputs.
- You can pick your input/output method from any answer with positive score on the default options. Please specify the method you pick in your answer.
1
's, you output the first substring you found. You identify the substrings with the index of the first character in that substring. Does that help? \$\endgroup\$