0
I came to the following algorithm to return true
if there is an incremental numeric sequence pattern +1
function sequenceSearch(vector) {
let pos = 0;
let found = 0;
for (pos = 0; pos <= vector.length - 1; pos++) {
if (vector[pos] + 1 === vector[pos + 1]) {
found++;
}
}
return found == 3 ? true : false;
}
However, in the function call need to pass an int value and not an array, as required in the represented algorithm. I wonder if there is a way to transform an integer value, example: int value = 1234
, in an array to be evaluated by the algorithm. ( Or some other more practical alternative to find the pattern)
Take the rest of the number division consecutively by 10, put it in your array and divide the number by 10 until it is <= 0. Your array will be with the digits in reverse order but you can easily treat this in your test.
– anonimo