솔루션 const solution = (M, N) => { const answer = M * N - 1; console.log(answer); return answer; };
솔루션1 const solution = (num, total) => { const numArray = Array.from({ length: num }, (_, i) => i); const sum = numArray.reduce((x, y) => x + y); const answer = numArray.map((v) => v - (sum - total) / num); console.log(answer); return answer; }; 솔루션2 const solution2 = (num, total) => { let answer = []; let ceilNum = Math.ceil(total / num - Math.floor(num / 2)); console.log(ceilNum); answer = Arra..
솔루션1 const solution = (common) => { const isTrue = (arr) => arr[2] - arr[1] === arr[1] - arr[0]; // 배열의 2번째 1번째 뺀 값이 1번째 0번째 뺀 값이랑 같니 console.log(isTrue(common)); // true, false const answer = isTrue(common) ? common[common.length - 1] + common[1] - common[0] // true면 등차수열 : common[common.length - 1] * (common[1] / common[0]); // false면 등비수열 console.log(answer); return answer; };
솔루션1 const convertPWordsToNum = (word) => { const pWords = ["aya", "ye", "woo", "ma"]; return pWords.reduce((result, pWord, i) => result.replaceAll(pWord, i), word); }; const canPronounce = (word) => { const result = convertPWordsToNum(word); return ( !/[^\d]/.test(result) && [...result].every( (num, i) => i + 1 > result.length || num !== result[i + 1] ) ); }; function solution(babbling) { conso..