PHP Code:
function ex1(a1, a2) {
temp.out = {};
temp.i = 0;
for (i = 0; i < a1.size() - 2; i ++) {
if (a2.pos(("" @ a1.subarray(i, 3))) > -1) {
out.add(a1.subarray(i, 3));
}
}
return out;
}
Am I doing it right?
That doesn't check if all the sets are exactly different, I'll do that next I guess.
You need to give examples of input and output >
PHP Code:
function ex1(a1, a2) {
temp.out = {};
temp.i = 0;
temp.sub = 0;
for (i = 0; i < a1.size() - 2; i ++) {
sub = ("" @ a1.subarray(i, 3));
if (a2.pos(sub) > -1) {
if (out.index(sub) < 0) {
out.add(sub);
i += 2;
}
}
}
return out;
}
It would be nice to have a variable.add2() function that only adds if the input isn't already in the array :o