Сообщение от Alexandroppolus
|
различить любую пару слов
|
let val1 = "abc5 abc0 abcde abcfg";
let val2 = "a5 abc0 abcde abcfg";
const fn = str => {
let words = str.split(/\s+/);
let length = Math.max(...words.map(_=>_.length)), i = 0;
k: for (; i < length; i++) {
let temp = "";
for(let a of words){
if (a[i] !== void 0){
if(temp.includes(a[i])) continue k;
temp += a[i];
}
}
return ++i
}
return i
}
console.log(fn(val1))
console.log(fn(val2))