this problem is multi-valued. it is equally valid to say that, in the case of the example, the stride associated with the longest skip sequence is -2.
Fair enough. I changed the wording to remove the ambiguity.
I added another test and rescored. It appears that DIST no longer works. The DIST function is from the Neural Networks Toolbox. It shouldn't have worked in the past, but since it did, it played a part in a lot of answers. Sorry for the discontinuity.
Tough !
Two years before understand that the sequence must contain only elements of a :)
I use a cheap for the last one. Any help with the last one?
this new implicit expansion functionality is a great excuse to revisit old problems :)
what does the dist function do?
'dist' just computes the euclidean distance between two lists of vectors (the dimensionality size(dist(a,b)) is the same as size(a*b)). In this case ~dist(a',a+s) is just the same as bsxfun(@eq,a',a+s), the matrix defining a directional graph of the elements of 'a' with distance 's'.
just for completion: the matrix above is nilpotent (with degree lower than the length of the vector a), if you sum all of its powers D=sum_n{C^n} (and this is what polyvalm does) you get a matrix where d(i,j)=1 if i is connected to j in this graph; it you then take the largets column sum of the result (this is what norm(D,1) does) you get the maximum length of a sequence with stride s (across all possible starting nodes in a)...
I am impressed.
i have no idea what dist or dmperm are/do...
wow, very nice double arrayfun
they were once for loops
10620 Solvers
11507 Solvers
Maximum running product for a string of numbers
1281 Solvers
284 Solvers
(Linear) Recurrence Equations - Generalised Fibonacci-like sequences
178 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!