옹알이(1)

let muSsg = ["aya", "ye", "woo", "ma"];
let newMuSsg;
let newMuSsgTwo = [];
for(let i in muSsg) {
    for(let j in muSsg) {
        if(muSsg[i] !== muSsg[j]) {
            newMuSsg = [muSsg[i], muSsg[j]];
            newMuSsgTwo.push(newMuSsg);
        }
    }
}
console.log(newMuSsgTwo);
let result = [];

for(let i in newMuSsgTwo) {
    result.push(newMuSsgTwo[i].join(''));
}
console.log(result);

let newMuSsgThree;
let newMuSsgFour = [];
for(let i in newMuSsgTwo) {
    for(let j in muSsg) {
        if(!newMuSsgTwo[i].includes(muSsg[j])) {
            newMuSsgThree = newMuSsgTwo[i].concat(muSsg[j]);
            newMuSsgFour.push(newMuSsgThree);
        }
    }
}
console.log(newMuSsgFour);

for(let i in newMuSsgFour) {
    result.push(newMuSsgFour[i].join(''));
}
console.log(result);

let newMuSsgFive;
let newMuSsgSix = [];
for(let i in newMuSsgFour) {
    for(let j in muSsg) {
        if(!newMuSsgFour[i].includes(muSsg[j])) {
            newMuSsgFive = newMuSsgFour[i].concat(muSsg[j]);
            newMuSsgSix.push(newMuSsgFive);
        }
    }
}
console.log(newMuSsgSix);

for(let i in newMuSsgSix) {
    result.push(newMuSsgSix[i].join(''));
}
console.log(result);

let newResult = result.concat(muSsg);

console.log(newResult);

function solution(babbling) {
    let answer = 0;
    for(let i in babbling) {
        if(newResult.includes(babbling[i])){
            answer += 1;
        }
    }
    return answer;
}

solution(["ayaye", "uuuma", "ye", "yemawoo", "ayaa"]); // 3

function solution(babbling) {
    let df = [ "aya", "ye", "woo", "ma"];
    let res = 0;
    for(let w of babbling) {
        if(df.some(f => w.includes(f+f))) continue;

        let rest = 
           df.reduce((a, f) => a.replaceAll(f, ""), w);

        if (rest.length > 0) continue;

        res++;
    }

    return res;
}

평행

틀림!!

function solution(dots) {
    let result = 0;
    let newarr = [];
    for(let x in dots) {
        for(let y in dots) {
            if(x !== y && dots[x][0] >= dots[y][0]) {
                let first = dots[x][0] - dots[y][0];
                let second = dots[x][1] - dots[y][1];
                newarr.push([first, second]);
            }
        }
    }
    console.log(newarr);
    for(let i in newarr){
        for(let j in newarr){
            if(i !== j && newarr[i][0] >= newarr[j][0]) {
                let third = newarr[i][0] - newarr[j][0];
                let fourth = newarr[i][1] - newarr[j][1];
                if(third === 0 && fourth === 0) {
                    return 1;
                }
            }
        }
    }
    return result;
}

let something = [[1, 4], [9, 2], [3, 8], [11, 6]];
console.log(solution(something));

function solution(dots) {
    let result = 0;
    let newarr = [];
    for(let x in dots) {
        for(let y in dots) {
            if(x !== y && dots[x][0] >= dots[y][0]) {
                let first = dots[x][0] - dots[y][0];
                let second = dots[x][1] - dots[y][1];
                const curl = first / second;
                if(newarr.includes(curl)){
                    return 1;
                }
                newarr.push(curl);
            }
        }
    }
    return result;
}

기울기 = y값의 증가량/x값의 증가량

카테고리:

태그:

업데이트:

댓글남기기