Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions 주중8B/eunhye/week05/영어 끝말잇기.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function solution(n, words) {
let arr = [];
for (let i = 0; i < words.length; i++) {
if (i === 0) arr.push(words[i]);
else if (
!arr.includes(words[i]) &&
words[i - 1][words[i - 1].length - 1] === words[i][0]
) {
arr.push(words[i]);
} else {
return [(i % n) + 1, parseInt(i / n) + 1];
}
}

return [0, 0];
}
8 changes: 8 additions & 0 deletions 주중8B/eunhye/week05/완주하지 못한 선수.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function solution(participant, completion) {
completion.sort();
participant.sort();

return participant.filter((el, idx) => {
if(completion[idx] !== el) return el;
})[0]
}
13 changes: 13 additions & 0 deletions 주중8B/eunhye/week05/카펫.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function solution(brown, yellow) {
const box = brown + yellow;
const mid = Math.floor(box/2);
for(let i=mid; i>0; i--) {
if(box%i !== 0) continue;

const w = i;
const h = box / i;
if((w-2) * (h-2) === yellow){
return [w, h]
}
}
}
14 changes: 14 additions & 0 deletions 주중8B/eunhye/week05/푸드 파이트 대회.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function solution(food) {
// 왼쪽부터 만들어서 0넣고 뒤집기
// 음식 종류와 양이 같아야 해서 1개 갖고 오면 못 먹음
const arr = [];

food.forEach((el, idx) => {
if(el >= 2) {
const eat = Math.floor(el/2);
// repeat은 ... number type에 안 먹는다...
arr.push(String(idx).repeat(eat));
}
})
return arr.join('') + 0 + arr.reverse().join('');
}