diff --git a/Challenge/UihyunLee/everyArray/README.md b/Challenge/UihyunLee/everyArray/README.md new file mode 100644 index 00000000..442558f6 --- /dev/null +++ b/Challenge/UihyunLee/everyArray/README.md @@ -0,0 +1,9 @@ +# 문제제목 + +## 설명 + +every를 이용해서 모든 원소가 짝수인지 아닌지를 판별하세요 + +## Expected Output + +true \ No newline at end of file diff --git a/Challenge/UihyunLee/everyArray/solve.js b/Challenge/UihyunLee/everyArray/solve.js new file mode 100644 index 00000000..b0892aaf --- /dev/null +++ b/Challenge/UihyunLee/everyArray/solve.js @@ -0,0 +1,3 @@ +function solution(inputArray) {} + +exports.solution = solution; diff --git a/Challenge/UihyunLee/everyArray/solve.test.js b/Challenge/UihyunLee/everyArray/solve.test.js new file mode 100644 index 00000000..b03e4791 --- /dev/null +++ b/Challenge/UihyunLee/everyArray/solve.test.js @@ -0,0 +1,21 @@ +const { solution } = require('./solve'); + +const test1 = { + input: [2, 4, 6, 8, 10], + answer: true, +}; + +const test2 = { + input: [2, 3, 6, 8, 10], + answer: false, +}; + +describe('everyArray', () => { + test('모두 짝수면 true여야 한다.', () => { + expect(solution(test1.input)).toEqual(test1.answer); + }); + + test('홀수가 있으면 false여야 한다.', () => { + expect(solution(test2.input)).toEqual(test2.answer); + }); +}); diff --git a/Challenge/UihyunLee/expDivOdd/README.md b/Challenge/UihyunLee/expDivOdd/README.md new file mode 100644 index 00000000..c07ab10b --- /dev/null +++ b/Challenge/UihyunLee/expDivOdd/README.md @@ -0,0 +1,3 @@ +## 설명 + +제곱한 후 3으로 나눈 나머지가 홀수인 것 을 뽑은 배열의 총 합을 구하세요. diff --git a/Challenge/UihyunLee/expDivOdd/solve.js b/Challenge/UihyunLee/expDivOdd/solve.js new file mode 100644 index 00000000..b0892aaf --- /dev/null +++ b/Challenge/UihyunLee/expDivOdd/solve.js @@ -0,0 +1,3 @@ +function solution(inputArray) {} + +exports.solution = solution; diff --git a/Challenge/UihyunLee/expDivOdd/solve.test.js b/Challenge/UihyunLee/expDivOdd/solve.test.js new file mode 100644 index 00000000..ca37fcc3 --- /dev/null +++ b/Challenge/UihyunLee/expDivOdd/solve.test.js @@ -0,0 +1,21 @@ +const { solution } = require('./solve'); + +const test1 = { + input: [1, 7, 3, 4, 6], + answer: 66, +}; + +const test2 = { + input: [2, 3, 6, 8, 10], + answer: 168, +}; + +describe('everyArray', () => { + test('1, 7, 3, 4, 6', () => { + expect(solution(test1.input)).toEqual(test1.answer); + }); + + test('2, 3, 6, 8, 10', () => { + expect(solution(test2.input)).toEqual(test2.answer); + }); +}); diff --git a/Challenge/UihyunLee/figureSkating/README.md b/Challenge/UihyunLee/figureSkating/README.md new file mode 100644 index 00000000..54b85fbd --- /dev/null +++ b/Challenge/UihyunLee/figureSkating/README.md @@ -0,0 +1,35 @@ +## 설명 + +점수를 계산해서 점수가 높은 순으로 name과 score를 가진 객체의 배열을 출력하세요. +단 실격자는 출력하지 않습니다. + +### 피겨 점수 기준 + +피겨 점수는 ‘기술점수(TES)+예술점수(PCS)-감점’으로 구성된다. + +기술점수(TES·Total Element Score)는 기본점수에 수행점수(GOE·Grade Of Execution)를 합산해 도출한다. + +심판은 선수들이 점프와 스핀의 기술을 제대로 수행하는지 살핀다. 점프에선 회전수를 제대로 지켰는지, 에지를 제대로 사용했는지에 따라 ‘롱 에지’(잘못된 에지 사용)나 ‘다운그레이드’(난이도 하락), ‘어텐션’(주의) 등의 판정을 내린다. 스핀과 스텝시퀀스에 붙는 레벨(1~4)도 이들이 결정한다. + +9명의 심판은 선수들이 미리 제출한 연기 구성표를 기준으로 과제별 기본점수에서 가·감점을 한다. 이른바 ‘GOE’라 불리는 수행점수다. + +쇼트프로그램은 점프 3개, 스핀 3개, 스텝 1개의 수행과제가 반드시 포함돼야 한다. + +예술점수(PCS·Total Program Component Score)는 프로그램의 완성도에 영향을 미치는 스케이팅 기술·동작의 연결·연기·안무·곡 해석 등 5가지를 평가한다. + +마지막으로 감점이 반영된다. 감점 항목이 발생할 때마다 1점씩 감점된다. + +원문보기: +http://news.khan.co.kr/kh_news/khan_art_view.html?art_id=201402172146545#csidx6329aebb6a02152bca884614a7f0544 + +### 판정 기준 + +- 점수가 가장 높은 사람이 1등이다. +- 점수는 기술점수(TES) + 예술점수(PCS) - 감점 으로 구성된다. +- 기술점수(TES)는 기본점수 \* 수행점수(GOE)를 합산해 도출한다. +- 필수 수행과제를 수행하지 못했을 시 실격이다. + +### 필수 수행과제 + +- 쇼트프로그램은 점프 3개, 스핀 3개, 스텝 1개의 수행과제가 반드시 포함돼야 한다. +- 점프와 스핀을 4번 이상 수행했을 시 가장 잘한 3개를 기준으로 한다. diff --git a/Challenge/UihyunLee/figureSkating/solve.js b/Challenge/UihyunLee/figureSkating/solve.js new file mode 100644 index 00000000..fc0d9664 --- /dev/null +++ b/Challenge/UihyunLee/figureSkating/solve.js @@ -0,0 +1,18 @@ +// 기본 점수 +const baseScore = { + jump: 10, + spin: 20, + step: 15, +}; + +const baseAssignment = { + jump: 3, + spin: 3, + step: 1, +}; + +// write your codes + +function solution(inputArray) {} + +exports.solution = solution; diff --git a/Challenge/UihyunLee/figureSkating/solve.test.js b/Challenge/UihyunLee/figureSkating/solve.test.js new file mode 100644 index 00000000..7bceadf1 --- /dev/null +++ b/Challenge/UihyunLee/figureSkating/solve.test.js @@ -0,0 +1,46 @@ +const { solution } = require('./solve'); + +const test1 = { + input: [ + { + name: '김연아', + goe: { + jump: [10, 9, 10], + spin: [10, 10, 10], + step: [9], + }, + pcs: 30, + penalty: 0, + }, + { + name: '피겨의 신', + goe: { + jump: [10000, 10000], + spin: [10000, 10000, 10000], + step: [10000], + }, + pcs: 100000, + penalty: 0, + }, + { + name: '아사다 마오', + goe: { + jump: [9, 6, 8, 9], + spin: [9, 9, 9], + step: [8], + }, + pcs: 29, + penalty: 10, + }, + ], + answer: [ + { name: '김연아', score: 1055 }, + { name: '아사다 마오', score: 939 }, + ], +}; + +describe('everyArray', () => { + test('test1', () => { + expect(solution(test1.input)).toEqual(test1.answer); + }); +}); diff --git a/Challenge/UihyunLee/filterAge/README.md b/Challenge/UihyunLee/filterAge/README.md new file mode 100644 index 00000000..873a15c1 --- /dev/null +++ b/Challenge/UihyunLee/filterAge/README.md @@ -0,0 +1,3 @@ +## 설명 + +배열 원소의 age가 30이상 50미만인 사람만 있는 객체의 배열을 만드세요 diff --git a/Challenge/UihyunLee/filterAge/solve.js b/Challenge/UihyunLee/filterAge/solve.js new file mode 100644 index 00000000..36baa9f8 --- /dev/null +++ b/Challenge/UihyunLee/filterAge/solve.js @@ -0,0 +1,4 @@ +// write your codes +function solution(inputArray) {} + +exports.solution = solution; diff --git a/Challenge/UihyunLee/filterAge/solve.test.js b/Challenge/UihyunLee/filterAge/solve.test.js new file mode 100644 index 00000000..b9081601 --- /dev/null +++ b/Challenge/UihyunLee/filterAge/solve.test.js @@ -0,0 +1,32 @@ +const { solution } = require('./solve'); + +const test1 = { + input: [ + { + name: '영미', + age: 25, + }, + { + name: '일미', + age: 35, + }, + { + name: '이미', + age: 45, + }, + { + name: '삼미', + age: 55, + }, + ], + answer: [ + { name: '일미', age: 35 }, + { name: '이미', age: 45 }, + ], +}; + +describe('filterAge', () => { + test('test1', () => { + expect(solution(test1.input)).toEqual(test1.answer); + }); +}); diff --git a/Challenge/UihyunLee/filterIntersection/README.md b/Challenge/UihyunLee/filterIntersection/README.md new file mode 100644 index 00000000..d7c9ad39 --- /dev/null +++ b/Challenge/UihyunLee/filterIntersection/README.md @@ -0,0 +1,5 @@ +# 문제제목 + +## 설명 + +두 배열의 교집합을 출력하세요! diff --git a/Challenge/UihyunLee/filterIntersection/solve.js b/Challenge/UihyunLee/filterIntersection/solve.js new file mode 100644 index 00000000..9bc832f1 --- /dev/null +++ b/Challenge/UihyunLee/filterIntersection/solve.js @@ -0,0 +1,3 @@ +function solution(inputArray1, inputArray2) {} + +exports.solution = solution; diff --git a/Challenge/UihyunLee/filterIntersection/solve.test.js b/Challenge/UihyunLee/filterIntersection/solve.test.js new file mode 100644 index 00000000..576cbc86 --- /dev/null +++ b/Challenge/UihyunLee/filterIntersection/solve.test.js @@ -0,0 +1,15 @@ +const { solution } = require('./solve'); + +const test1 = { + input: { + A: [1, 2, 3, 4, 5], + B: [3, 4, 5, 6, 7], + }, + answer: [3, 4, 5], +}; + +describe('filterIntersection', () => { + test('test1', () => { + expect(solution(test1.input.A, test1.input.B)).toEqual(test1.answer); + }); +}); diff --git a/Challenge/UihyunLee/filterOdd/README.md b/Challenge/UihyunLee/filterOdd/README.md new file mode 100644 index 00000000..cf9eda79 --- /dev/null +++ b/Challenge/UihyunLee/filterOdd/README.md @@ -0,0 +1,3 @@ +## 설명 + +홀수만 뽑아 배열로 만드세요 diff --git a/Challenge/UihyunLee/filterOdd/solve.js b/Challenge/UihyunLee/filterOdd/solve.js new file mode 100644 index 00000000..36baa9f8 --- /dev/null +++ b/Challenge/UihyunLee/filterOdd/solve.js @@ -0,0 +1,4 @@ +// write your codes +function solution(inputArray) {} + +exports.solution = solution; diff --git a/Challenge/UihyunLee/filterOdd/solve.test.js b/Challenge/UihyunLee/filterOdd/solve.test.js new file mode 100644 index 00000000..8cfd7f5a --- /dev/null +++ b/Challenge/UihyunLee/filterOdd/solve.test.js @@ -0,0 +1,28 @@ +const { solution } = require('./solve'); + +const test1 = { + input: [4, 2, 5, 1, 3], + answer: [5, 1, 3], +}; + +const test2 = { + input: [4, 2, 6, 8, 50, 16], + answer: [], +}; + +const test3 = { + input: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], + answer: [1, 3, 5, 7, 9, 11], +}; + +describe('filterOdd', () => { + test('test1', () => { + expect(solution(test1.input)).toEqual(test1.answer); + }); + test('test2', () => { + expect(solution(test2.input)).toEqual(test2.answer); + }); + test('test3', () => { + expect(solution(test3.input)).toEqual(test3.answer); + }); +}); diff --git a/Challenge/UihyunLee/findWord/README.md b/Challenge/UihyunLee/findWord/README.md new file mode 100644 index 00000000..8ef123f4 --- /dev/null +++ b/Challenge/UihyunLee/findWord/README.md @@ -0,0 +1,9 @@ +# 문제제목 + +## 설명 + +용가리라는 단어가 있으면 true 없으면 false를 출력 + +## Expected Output + +true diff --git a/Challenge/UihyunLee/findWord/solve.js b/Challenge/UihyunLee/findWord/solve.js new file mode 100644 index 00000000..36baa9f8 --- /dev/null +++ b/Challenge/UihyunLee/findWord/solve.js @@ -0,0 +1,4 @@ +// write your codes +function solution(inputArray) {} + +exports.solution = solution; diff --git a/Challenge/UihyunLee/findWord/solve.test.js b/Challenge/UihyunLee/findWord/solve.test.js new file mode 100644 index 00000000..804114f6 --- /dev/null +++ b/Challenge/UihyunLee/findWord/solve.test.js @@ -0,0 +1,26 @@ +const { solution } = require('./solve'); + +const test1 = { + input: ['잠', '자', '고', '싶', '다', '용가리'], + answer: true, +}; +const test2 = { + input: ['맛있는', '용가리치킨'], + answer: false, +}; +const test3 = { + input: ['고질라', '용가리 ', '울트라맨'], + answer: false, +}; + +describe('findWord', () => { + test('test1', () => { + expect(solution(test1.input)).toEqual(test1.answer); + }); + test('test2', () => { + expect(solution(test2.input)).toEqual(test2.answer); + }); + test('test3', () => { + expect(solution(test3.input)).toEqual(test3.answer); + }); +}); \ No newline at end of file diff --git a/Challenge/UihyunLee/forEachFilter/README.md b/Challenge/UihyunLee/forEachFilter/README.md new file mode 100644 index 00000000..6dcbc7c2 --- /dev/null +++ b/Challenge/UihyunLee/forEachFilter/README.md @@ -0,0 +1,3 @@ +## 설명 + +배열 원소중 40 이상인 수만 뽑아 배열을 만드세요. diff --git a/Challenge/UihyunLee/forEachFilter/solve.js b/Challenge/UihyunLee/forEachFilter/solve.js new file mode 100644 index 00000000..17f8be8e --- /dev/null +++ b/Challenge/UihyunLee/forEachFilter/solve.js @@ -0,0 +1,12 @@ +// write your codes +function solution(inputArray) {} + +exports.solution = solution; + +let answer = []; + +inputArray((item)=>{ + if(item>=40){ + answer.push(item); + } +}); diff --git a/Challenge/UihyunLee/forEachFilter/solve.test.js b/Challenge/UihyunLee/forEachFilter/solve.test.js new file mode 100644 index 00000000..3d73b25c --- /dev/null +++ b/Challenge/UihyunLee/forEachFilter/solve.test.js @@ -0,0 +1,12 @@ +const { solution } = require('./solve'); + +const test1 = { + input: [100, 10, 20, 40], + answer: [100, 40], +}; + +describe('forEachFilter', () => { + test('test1', () => { + expect(solution(test1.input)).toEqual(test1.answer); + }); +}); diff --git a/Challenge/UihyunLee/forEachFilterIsNaN/README.md b/Challenge/UihyunLee/forEachFilterIsNaN/README.md new file mode 100644 index 00000000..570c030e --- /dev/null +++ b/Challenge/UihyunLee/forEachFilterIsNaN/README.md @@ -0,0 +1,3 @@ +## 설명 + +배열 원소중 숫자인 원소만 뽑아 배열을 만드세요. diff --git a/Challenge/UihyunLee/forEachFilterIsNaN/solve.js b/Challenge/UihyunLee/forEachFilterIsNaN/solve.js new file mode 100644 index 00000000..b49420d5 --- /dev/null +++ b/Challenge/UihyunLee/forEachFilterIsNaN/solve.js @@ -0,0 +1,8 @@ +// write your codes +function solution(inputArray) {} + +exports.solution = solution; + +let answer = []; + +answer = inputArray.filter((item)=>item===Number(item)); \ No newline at end of file diff --git a/Challenge/UihyunLee/forEachFilterIsNaN/solve.test.js b/Challenge/UihyunLee/forEachFilterIsNaN/solve.test.js new file mode 100644 index 00000000..d6e118bb --- /dev/null +++ b/Challenge/UihyunLee/forEachFilterIsNaN/solve.test.js @@ -0,0 +1,28 @@ +const { solution } = require('./solve'); + +const test1 = { + input: [1, 40, '라매', '개발자', 51.5, 'a', 88], + answer: [1, 40, 51.5, 88], +}; + +const test2 = { + input: [1, 2, 3, '4', 5, '6'], + answer: [1, 2, 3, 5], +}; + +const test3 = { + input: [-3, -2, -1, 0, 1, 2, 3], + answer: [-3, -2, -1, 0, 1, 2, 3], +}; + +describe('forEachFilterIsNaN', () => { + test('test1: 숫자,문자 판별', () => { + expect(solution(test1.input)).toEqual(test1.answer); + }); + test('test2: 문자로된 숫자 판별', () => { + expect(solution(test2.input)).toEqual(test2.answer); + }); + test('test3: 음수 양수 포함', () => { + expect(solution(test3.input)).toEqual(test3.answer); + }); +}); \ No newline at end of file diff --git a/Challenge/UihyunLee/forEachMap/README.md b/Challenge/UihyunLee/forEachMap/README.md new file mode 100644 index 00000000..1e8e03c8 --- /dev/null +++ b/Challenge/UihyunLee/forEachMap/README.md @@ -0,0 +1,3 @@ +## 설명 + +forEach 메소드를 사용해서 배열의 각 원소 끝에 '%'를 붙인 문자열 배열을 출력하세요 diff --git a/Challenge/UihyunLee/forEachMap/solve.js b/Challenge/UihyunLee/forEachMap/solve.js new file mode 100644 index 00000000..a1e8f0ad --- /dev/null +++ b/Challenge/UihyunLee/forEachMap/solve.js @@ -0,0 +1,12 @@ +// write your codes +function solution(inputArray) {} + +exports.solution = solution; + +let answer = []; + +inputArray.forEach((item)=>{ + answer.push(item+'%'); +}); + +console.log(answer); \ No newline at end of file diff --git a/Challenge/UihyunLee/forEachMap/solve.test.js b/Challenge/UihyunLee/forEachMap/solve.test.js new file mode 100644 index 00000000..de4868c6 --- /dev/null +++ b/Challenge/UihyunLee/forEachMap/solve.test.js @@ -0,0 +1,12 @@ +const { solution } = require('./solve'); + +const test1 = { + input: [100, 10, 20, 40], + answer: ['100%', '10%', '20%', '40%'], +}; + +describe('forEachMap', () => { + test('test1', () => { + expect(solution(test1.input)).toEqual(test1.answer); + }); +}); diff --git a/Challenge/UihyunLee/forEachReduce/README.md b/Challenge/UihyunLee/forEachReduce/README.md new file mode 100644 index 00000000..a984df2d --- /dev/null +++ b/Challenge/UihyunLee/forEachReduce/README.md @@ -0,0 +1,3 @@ +## 설명 + +forEach 메소드를 사용해서 배열의 총 합을 출력하는 코드를 작성하세요 diff --git a/Challenge/UihyunLee/forEachReduce/solve.js b/Challenge/UihyunLee/forEachReduce/solve.js new file mode 100644 index 00000000..a90d0f8b --- /dev/null +++ b/Challenge/UihyunLee/forEachReduce/solve.js @@ -0,0 +1,12 @@ +// write your codes +function solution(inputArray) {} + +exports.solution = solution; + +let answer; + +inputArray.forEach((item)=>{ + answer+=item; +}); + +console.log(answer); \ No newline at end of file diff --git a/Challenge/UihyunLee/forEachReduce/solve.test.js b/Challenge/UihyunLee/forEachReduce/solve.test.js new file mode 100644 index 00000000..397e4b50 --- /dev/null +++ b/Challenge/UihyunLee/forEachReduce/solve.test.js @@ -0,0 +1,28 @@ +const { solution } = require('./solve'); + +const test1 = { + input: [100, 10, 20, 40], + answer: 170, +}; + +const test2 = { + input: [120, -20, -30, 0, 15], + answer: 85, +}; + +const test3 = { + input: [-10, -20, -30], + answer: -60, +}; + +describe('forEachReduce', () => { + test('test1', () => { + expect(solution(test1.input)).toEqual(test1.answer); + }); + test('test2: 음수가 포함된 계산', () => { + expect(solution(test2.input)).toEqual(test2.answer); + }); + test('test3: 음수만 존재하는 계산', () => { + expect(solution(test3.input)).toEqual(test3.answer); + }); +}); diff --git a/Challenge/UihyunLee/mapAddPercent/README.md b/Challenge/UihyunLee/mapAddPercent/README.md new file mode 100644 index 00000000..75e73042 --- /dev/null +++ b/Challenge/UihyunLee/mapAddPercent/README.md @@ -0,0 +1,3 @@ +## 설명 + +map 메소드를 사용해 배열 각각 숫자 뒤에 %를 붙인 문자열을 만드세요 diff --git a/Challenge/UihyunLee/mapAddPercent/solve.js b/Challenge/UihyunLee/mapAddPercent/solve.js new file mode 100644 index 00000000..5f359c24 --- /dev/null +++ b/Challenge/UihyunLee/mapAddPercent/solve.js @@ -0,0 +1,8 @@ +// write your codes +function solution(inputArray) {} + +exports.solution = solution; + +let answer = inputArray.map((item)=>item+'%'); + +console.log(answer); \ No newline at end of file diff --git a/Challenge/UihyunLee/mapAddPercent/solve.test.js b/Challenge/UihyunLee/mapAddPercent/solve.test.js new file mode 100644 index 00000000..dac1b3cc --- /dev/null +++ b/Challenge/UihyunLee/mapAddPercent/solve.test.js @@ -0,0 +1,12 @@ +const { solution } = require('./solve'); + +const test1 = { + input: [100, 10, 20, 40], + answer: ['100%', '10%', '20%', '40%'], +}; + +describe('mapAddPercent', () => { + test('test1', () => { + expect(solution(test1.input)).toEqual(test1.answer); + }); +}); diff --git a/Challenge/UihyunLee/mapAppendOrder/README.md b/Challenge/UihyunLee/mapAppendOrder/README.md new file mode 100644 index 00000000..1435623a --- /dev/null +++ b/Challenge/UihyunLee/mapAppendOrder/README.md @@ -0,0 +1,3 @@ +## 설명 + +배열의 값을 name 프로퍼티에 넣고 몇번째 원소인지를 order에 넣은 객체의 배열을 출력하세요 diff --git a/Challenge/UihyunLee/mapAppendOrder/solve.js b/Challenge/UihyunLee/mapAppendOrder/solve.js new file mode 100644 index 00000000..4cbf041c --- /dev/null +++ b/Challenge/UihyunLee/mapAppendOrder/solve.js @@ -0,0 +1,14 @@ +// write your codes +function solution(inputArray) {} + +exports.solution = solution; + +const answer = inputArray.map((item,idx)=>{ + return{ + name : item, + order : idx+1 + }; +}); + +console.log(answer) + diff --git a/Challenge/UihyunLee/mapAppendOrder/solve.test.js b/Challenge/UihyunLee/mapAppendOrder/solve.test.js new file mode 100644 index 00000000..e08db10c --- /dev/null +++ b/Challenge/UihyunLee/mapAppendOrder/solve.test.js @@ -0,0 +1,16 @@ +const { solution } = require('./solve'); + +const test1 = { + input: ['홍길동', '둘리', '루피'], + answer: [ + { name: '홍길동', order: 1 }, + { name: '둘리', order: 2 }, + { name: '루피', order: 3 }, + ], +}; + +describe('mapAppendOrder', () => { + test('test1', () => { + expect(solution(test1.input)).toEqual(test1.answer); + }); +}); diff --git a/Challenge/UihyunLee/recommendAd/README.md b/Challenge/UihyunLee/recommendAd/README.md new file mode 100644 index 00000000..132e8800 --- /dev/null +++ b/Challenge/UihyunLee/recommendAd/README.md @@ -0,0 +1,15 @@ +# 문제제목 + +사용자가 안 본 광고는? + +## 설명 + +유튜브는 사용자가 프리미엄 회원이 아닌 경우 영상 시작이나 중간에 광고가 나오도록 설정되어 있습니다. + +[2020년 유튜브 인기 광고](https://www.thinkwithgoogle.com/intl/ko-kr/marketing-strategies/video/%EB%8C%80%ED%95%9C%EB%AF%BC%EA%B5%AD-youtube-%EC%9D%B8%EA%B8%B0-%EA%B4%91%EA%B3%A0%EC%98%81%EC%83%81-2020%EB%85%84-%EC%97%B0%EB%A7%90%EA%B2%B0%EC%82%B0/)는 총 열 편으로, 사용자의 일주일간 광고 시청 이력을 통해 해당 사용자가 일주일 동안 안 본 광고를 그 다음주에 노출함으로써 광고들이 사용자에게 골고루 노출되길 원합니다. + +유저가 매일 유튜브에 접속하여 하루 한 편 이상의 광고를 보았다고 가정할 때, 이 유저가 안 본 광고는 무엇인지 출력해주세요. + +## Expected Output + +[ '동원F&B' ] diff --git a/Challenge/UihyunLee/recommendAd/solve.js b/Challenge/UihyunLee/recommendAd/solve.js new file mode 100644 index 00000000..f706fa97 --- /dev/null +++ b/Challenge/UihyunLee/recommendAd/solve.js @@ -0,0 +1,26 @@ +const userHistory = [ + { date: '2020-11-03', watched: ['KT', 'BBQ'] }, + { date: '2020-11-04', watched: ['정관장', 'KT', '딱좋은데이'] }, + { date: '2020-11-05', watched: ['그랑사가', '농심'] }, + { date: '2020-11-06', watched: ['BBQ'] }, + { date: '2020-11-07', watched: ['쌍용자동차', 'BBQ', 'KT'] }, + { date: '2020-11-08', watched: ['켈로그코리아', '빙그레'] }, + { date: '2020-11-09', watched: ['KT', '그랑사가', '빙그레'] }, +]; + +// write your codes + +function solution(inputArray){ + let watch_array = userHistory.map((item)=>item[watched]); + let set = new Set(); + watch_array.forEach((item)=>{ + item.forEach(i=>{ + set.add(i); + }); + }); + return inputArray.filter((item)=>!set.has(item)); +} + +exports.solution = solution; + + diff --git a/Challenge/UihyunLee/recommendAd/solve.test.js b/Challenge/UihyunLee/recommendAd/solve.test.js new file mode 100644 index 00000000..8a0f6464 --- /dev/null +++ b/Challenge/UihyunLee/recommendAd/solve.test.js @@ -0,0 +1,23 @@ +const { solution } = require('./solve'); + +const test1 = { + input: [ + '동원F&B', + '정관장', + 'KT', + 'BBQ', + '그랑사가', + '농심', + '딱좋은데이', + '빙그레', + '쌍용자동차', + '켈로그코리아', + ], + answer: ['동원F&B'], +}; + +describe('recommendAd', () => { + test('test1', () => { + expect(solution(test1.input)).toEqual(test1.answer); + }); +}); diff --git a/Challenge/UihyunLee/reduceMaxValueNIndex/README.md b/Challenge/UihyunLee/reduceMaxValueNIndex/README.md new file mode 100644 index 00000000..965bdec6 --- /dev/null +++ b/Challenge/UihyunLee/reduceMaxValueNIndex/README.md @@ -0,0 +1,3 @@ +## 설명 + +reduce 메소드를 사용해 최댓값의 값을 maxValue에, 해당 값의 index를 idx에 넣은 객체를 출력하세요 diff --git a/Challenge/UihyunLee/reduceMaxValueNIndex/solve.js b/Challenge/UihyunLee/reduceMaxValueNIndex/solve.js new file mode 100644 index 00000000..36baa9f8 --- /dev/null +++ b/Challenge/UihyunLee/reduceMaxValueNIndex/solve.js @@ -0,0 +1,4 @@ +// write your codes +function solution(inputArray) {} + +exports.solution = solution; diff --git a/Challenge/UihyunLee/reduceMaxValueNIndex/solve.test.js b/Challenge/UihyunLee/reduceMaxValueNIndex/solve.test.js new file mode 100644 index 00000000..0daef5b8 --- /dev/null +++ b/Challenge/UihyunLee/reduceMaxValueNIndex/solve.test.js @@ -0,0 +1,28 @@ +const { solution } = require('./solve'); + +const test1 = { + input: [3, 29, 38, 12, 57, 74, 40, 85, 61], + answer: { maxValue: 85, idx: 7 }, +}; + +const test2 = { + input: [-24, -2, -13, -49, -999999, -17], + answer: { maxValue: -2, idx: 1 }, +}; +//최댓값이 중복일 때에는 먼저 나온 최댓값의 인덱스를 유지하도록 설정하였습니다. +const test3 = { + input: [2, -20, 21, -874, 99, -16, -29, 99], + answer: { maxValue: 99, idx: 4 }, +}; + +describe('reduceMaxValueNIndex', () => { + test('test1', () => { + expect(solution(test1.input)).toEqual(test1.answer); + }); + test('test2 : 음수 테스트', () => { + expect(solution(test2.input)).toEqual(test2.answer); + }); + test('test3 : 중복된 최대값 테스트', () => { + expect(solution(test3.input)).toEqual(test3.answer); + }); +}); diff --git a/Challenge/UihyunLee/reduceNameNickname/README.md b/Challenge/UihyunLee/reduceNameNickname/README.md new file mode 100644 index 00000000..b6920e05 --- /dev/null +++ b/Challenge/UihyunLee/reduceNameNickname/README.md @@ -0,0 +1,3 @@ +## 설명 + +입력받은 객채배열의 nickname을 key, name을 value로 하는 객체를 출력하세요 diff --git a/Challenge/UihyunLee/reduceNameNickname/solve.js b/Challenge/UihyunLee/reduceNameNickname/solve.js new file mode 100644 index 00000000..36baa9f8 --- /dev/null +++ b/Challenge/UihyunLee/reduceNameNickname/solve.js @@ -0,0 +1,4 @@ +// write your codes +function solution(inputArray) {} + +exports.solution = solution; diff --git a/Challenge/UihyunLee/reduceNameNickname/solve.test.js b/Challenge/UihyunLee/reduceNameNickname/solve.test.js new file mode 100644 index 00000000..67b74529 --- /dev/null +++ b/Challenge/UihyunLee/reduceNameNickname/solve.test.js @@ -0,0 +1,25 @@ +const { solution } = require('./solve'); + +const test1 = { + input: [ + { + name: '홍길동', + nickname: 'hong', + }, + { + name: '둘리', + nickname: '2li', + }, + { + name: '오스트랄로피테쿠스', + nickname: '1Cin', + }, + ], + answer: { hong: '홍길동', '2li': '둘리', '1Cin': '오스트랄로피테쿠스' }, +}; + +describe('reduceNameNickname', () => { + test('test1', () => { + expect(solution(test1.input)).toEqual(test1.answer); + }); +}); diff --git a/Challenge/UihyunLee/reduceSum/README.md b/Challenge/UihyunLee/reduceSum/README.md new file mode 100644 index 00000000..8c607eb2 --- /dev/null +++ b/Challenge/UihyunLee/reduceSum/README.md @@ -0,0 +1,9 @@ +# 문제제목 + +## 설명 + +reduce 메소드를 사용해서 배열의 모든 수의 합을 구하세요. + +## Expected Output + +106 diff --git a/Challenge/UihyunLee/reduceSum/solve.js b/Challenge/UihyunLee/reduceSum/solve.js new file mode 100644 index 00000000..36baa9f8 --- /dev/null +++ b/Challenge/UihyunLee/reduceSum/solve.js @@ -0,0 +1,4 @@ +// write your codes +function solution(inputArray) {} + +exports.solution = solution; diff --git a/Challenge/UihyunLee/reduceSum/solve.test.js b/Challenge/UihyunLee/reduceSum/solve.test.js new file mode 100644 index 00000000..046c40cb --- /dev/null +++ b/Challenge/UihyunLee/reduceSum/solve.test.js @@ -0,0 +1,12 @@ +const { solution } = require('./solve'); + +const test1 = { + input: [10, 3, 20, 5, 8, 60], + answer: 106, +}; + +describe('reduceSum', () => { + test('test1', () => { + expect(solution(test1.input)).toEqual(test1.answer); + }); +}); diff --git a/Challenge/UihyunLee/sortByPrice/README.md b/Challenge/UihyunLee/sortByPrice/README.md new file mode 100644 index 00000000..b1ccf70e --- /dev/null +++ b/Challenge/UihyunLee/sortByPrice/README.md @@ -0,0 +1,14 @@ +# 문제제목 + +## 설명 + +배열안의 객체를 price를 기준으로 오름차순 정렬한 배열을 출력하세요 + +## Expected Output + +[ + { name: '사과', price: 1000 }, + { name: '당근', price: 2000 }, + { name: '수박', price: 5000 }, + { name: '참외', price: 10000 } +] diff --git a/Challenge/UihyunLee/sortByPrice/solve.js b/Challenge/UihyunLee/sortByPrice/solve.js new file mode 100644 index 00000000..36baa9f8 --- /dev/null +++ b/Challenge/UihyunLee/sortByPrice/solve.js @@ -0,0 +1,4 @@ +// write your codes +function solution(inputArray) {} + +exports.solution = solution; diff --git a/Challenge/UihyunLee/sortByPrice/solve.test.js b/Challenge/UihyunLee/sortByPrice/solve.test.js new file mode 100644 index 00000000..3d6a3431 --- /dev/null +++ b/Challenge/UihyunLee/sortByPrice/solve.test.js @@ -0,0 +1,34 @@ +const { solution } = require('./solve'); + +const test1 = { + input: [ + { + name: '사과', + price: 1000, + }, + { + name: '수박', + price: 5000, + }, + { + name: '당근', + price: 2000, + }, + { + name: '참외', + price: 10000, + }, + ], + answer: [ + { name: '사과', price: 1000 }, + { name: '당근', price: 2000 }, + { name: '수박', price: 5000 }, + { name: '참외', price: 10000 }, + ], +}; + +describe('sortByPrice', () => { + test('test1', () => { + expect(solution(test1.input)).toEqual(test1.answer); + }); +}); diff --git a/Challenge/UihyunLee/sortByPriceAndQuantity/README.md b/Challenge/UihyunLee/sortByPriceAndQuantity/README.md new file mode 100644 index 00000000..41cd5c95 --- /dev/null +++ b/Challenge/UihyunLee/sortByPriceAndQuantity/README.md @@ -0,0 +1,16 @@ +# 문제제목 + +## 설명 + +배열안의 객체를 price를 기준으로 오름차순 정렬한 배열을 출력하세요 +만약 price가 같다면 quantity기준으로 오름차순 정렬하세요 + +## Expected Output + +[ + { name: '사과', price: 1000, quantity: 2 }, + { name: '오이', price: 2000, quantity: 49 }, + { name: '당근', price: 2000, quantity: 50 }, + { name: '참외', price: 5000, quantity: 10 }, + { name: '수박', price: 5000, quantity: 20 } +] diff --git a/Challenge/UihyunLee/sortByPriceAndQuantity/solve.js b/Challenge/UihyunLee/sortByPriceAndQuantity/solve.js new file mode 100644 index 00000000..36baa9f8 --- /dev/null +++ b/Challenge/UihyunLee/sortByPriceAndQuantity/solve.js @@ -0,0 +1,4 @@ +// write your codes +function solution(inputArray) {} + +exports.solution = solution; diff --git a/Challenge/UihyunLee/sortByPriceAndQuantity/solve.test.js b/Challenge/UihyunLee/sortByPriceAndQuantity/solve.test.js new file mode 100644 index 00000000..424f42b7 --- /dev/null +++ b/Challenge/UihyunLee/sortByPriceAndQuantity/solve.test.js @@ -0,0 +1,44 @@ +const { solution } = require('./solve'); + +const test1 = { + input: [ + { + name: '사과', + price: 1000, + quantity: 2, + }, + { + name: '수박', + price: 5000, + quantity: 20, + }, + { + name: '당근', + price: 2000, + quantity: 50, + }, + { + name: '참외', + price: 5000, + quantity: 10, + }, + { + name: '오이', + price: 2000, + quantity: 49, + }, + ], + answer: [ + { name: '사과', price: 1000, quantity: 2 }, + { name: '오이', price: 2000, quantity: 49 }, + { name: '당근', price: 2000, quantity: 50 }, + { name: '참외', price: 5000, quantity: 10 }, + { name: '수박', price: 5000, quantity: 20 }, + ], +}; + +describe('sortByPriceAndQuantity', () => { + test('test1', () => { + expect(solution(test1.input)).toEqual(test1.answer); + }); +}); diff --git a/Challenge/UihyunLee/spreadOperatorMaxValue/README.md b/Challenge/UihyunLee/spreadOperatorMaxValue/README.md new file mode 100644 index 00000000..164b68a1 --- /dev/null +++ b/Challenge/UihyunLee/spreadOperatorMaxValue/README.md @@ -0,0 +1,3 @@ +## 설명 + +Spread Operator를 이용해서 값의 최대, 최소값을 구하세요 diff --git a/Challenge/UihyunLee/spreadOperatorMaxValue/solve.js b/Challenge/UihyunLee/spreadOperatorMaxValue/solve.js new file mode 100644 index 00000000..36baa9f8 --- /dev/null +++ b/Challenge/UihyunLee/spreadOperatorMaxValue/solve.js @@ -0,0 +1,4 @@ +// write your codes +function solution(inputArray) {} + +exports.solution = solution; diff --git a/Challenge/UihyunLee/spreadOperatorMaxValue/solve.test.js b/Challenge/UihyunLee/spreadOperatorMaxValue/solve.test.js new file mode 100644 index 00000000..26f2abf9 --- /dev/null +++ b/Challenge/UihyunLee/spreadOperatorMaxValue/solve.test.js @@ -0,0 +1,12 @@ +const { solution } = require('./solve'); + +const test1 = { + input: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], + answer: 'max : 10, min : 1', +}; + +describe('spreadOperatorMaxValue', () => { + test('test1', () => { + expect(solution(test1.input)).toEqual(test1.answer); + }); +});