Day 03
Tips
-
find the location of the largest number in a position that still leaves enough space to the right to fit the required number of digits (only 1 more in this case)
-
maxfunction returns both the maximum value and its index position, which is useful -
adjust your search range according to what the first
maxsearch returned
Second problem
-
a generalisation… now the search window size is variable because the values are
k=12digits long embedded within a string of lengthn=100digits -
the tricky bit is adjusting the
startandendpoints of the search window as each iteration goes alon. -
beware of off-by-one errors (I made a few of those… ;)
Code
Matlab solution
Matlab code / solution for the first part of that problem.
Second part solution of that problem.