From 6ddedbbfe3575c959efa42047118e51c9f90d6fd Mon Sep 17 00:00:00 2001 From: LeeJuyeon Date: Mon, 20 May 2019 17:42:13 +0900 Subject: [PATCH 1/7] programmers runner --- 190520/ruby/runner.js | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 190520/ruby/runner.js diff --git a/190520/ruby/runner.js b/190520/ruby/runner.js deleted file mode 100644 index 3181969..0000000 --- a/190520/ruby/runner.js +++ /dev/null @@ -1,12 +0,0 @@ - -const solution = (participant, completion) => { - let partiPeople = participant.sort(); - let completePeople = completion.sort(); - for ( let i = 0; i < partiPeople.length; i++ ) { - if ( partiPeople[i] !== completePeople[i] ) { - return partiPeople[i]; - } - } -} - -console.log( solution(["mislav", "stanko", "mislav", "ana"],["stanko", "ana", "mislav"]) ) \ No newline at end of file From ddd3a4cb97b87742c196dc97b2522de3c5a2b8b8 Mon Sep 17 00:00:00 2001 From: LeeJuyeon Date: Mon, 20 May 2019 17:43:58 +0900 Subject: [PATCH 2/7] programmers runner --- 190520/ruby/runner.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 190520/ruby/runner.js diff --git a/190520/ruby/runner.js b/190520/ruby/runner.js new file mode 100644 index 0000000..3181969 --- /dev/null +++ b/190520/ruby/runner.js @@ -0,0 +1,12 @@ + +const solution = (participant, completion) => { + let partiPeople = participant.sort(); + let completePeople = completion.sort(); + for ( let i = 0; i < partiPeople.length; i++ ) { + if ( partiPeople[i] !== completePeople[i] ) { + return partiPeople[i]; + } + } +} + +console.log( solution(["mislav", "stanko", "mislav", "ana"],["stanko", "ana", "mislav"]) ) \ No newline at end of file From 7843a662cb89795713c454e90b86d84b70654a9a Mon Sep 17 00:00:00 2001 From: LeeJuyeon Date: Tue, 21 May 2019 11:06:33 +0900 Subject: [PATCH 3/7] =?UTF-8?q?k=EB=B2=88=EC=A7=B8=20=EC=88=98=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=ED=92=80=EC=9D=B4=20-map=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=B4=EC=84=9C=20slice=20=EB=A1=9C=20answer=20=EC=97=90=20p?= =?UTF-8?q?ush?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 190521/k_number.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/190521/k_number.js b/190521/k_number.js index d49891a..3d66ad8 100644 --- a/190521/k_number.js +++ b/190521/k_number.js @@ -1,5 +1,15 @@ const solution = (arr, commands) => { +<<<<<<< HEAD let answer = commands.map( el => arr.slice(el[0]-1,el[1]).sort(sortFuc)[el[2]-1]) +======= + const answer = []; + const first = commands.map( el => el[0]-1 ); + const second = commands.map( el => el[1] ); + const third = commands.map( el => el[2]-1 ); + for ( let i = 0; i < first.length; i++ ){ + answer.push(arr.slice(first[i],second[i]).sort(sortFuc)[third[i]]); + } +>>>>>>> k번째 수 문제풀이 return answer; } From 999a9053003cf35a5a24ea764aad7b1d3e8f2070 Mon Sep 17 00:00:00 2001 From: LeeJuyeon Date: Tue, 21 May 2019 11:07:26 +0900 Subject: [PATCH 4/7] =?UTF-8?q?refactor=20:=20map=20=EC=A4=91=EB=B3=B5?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 190521/k_number.js | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 190521/k_number.js diff --git a/190521/k_number.js b/190521/k_number.js deleted file mode 100644 index 3d66ad8..0000000 --- a/190521/k_number.js +++ /dev/null @@ -1,16 +0,0 @@ -const solution = (arr, commands) => { -<<<<<<< HEAD - let answer = commands.map( el => arr.slice(el[0]-1,el[1]).sort(sortFuc)[el[2]-1]) -======= - const answer = []; - const first = commands.map( el => el[0]-1 ); - const second = commands.map( el => el[1] ); - const third = commands.map( el => el[2]-1 ); - for ( let i = 0; i < first.length; i++ ){ - answer.push(arr.slice(first[i],second[i]).sort(sortFuc)[third[i]]); - } ->>>>>>> k번째 수 문제풀이 - return answer; -} - -const sortFuc = (a,b) => {return a-b}; \ No newline at end of file From d94067bb49dff11765573ff7ba48607e668f65f6 Mon Sep 17 00:00:00 2001 From: LeeJuyeon Date: Fri, 24 May 2019 15:42:18 +0900 Subject: [PATCH 5/7] h-index solution --- 190524/ruby/solution.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 190524/ruby/solution.js diff --git a/190524/ruby/solution.js b/190524/ruby/solution.js new file mode 100644 index 0000000..fd42ca1 --- /dev/null +++ b/190524/ruby/solution.js @@ -0,0 +1,13 @@ +const solution = (c) => { + c.sort((a,b)=>b-a); + for(let i=0; i c[i]){ + return i + }else if(i+1 === c[i]){ + return c[i] + } + } + return c.length +} + +console.log(solution([1,1,3,4,8])) \ No newline at end of file From 17035194a86f4c3cca3dbd5ff67737b796e93bc1 Mon Sep 17 00:00:00 2001 From: LeeJuyeon Date: Tue, 28 May 2019 00:08:00 +0900 Subject: [PATCH 6/7] =?UTF-8?q?ruby=20=EB=AA=A8=EC=9D=98=EA=B3=A0=EC=82=AC?= =?UTF-8?q?=20=EB=AC=B8=EC=A0=9C=ED=92=80=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 190527/ruby/solution.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 190527/ruby/solution.js diff --git a/190527/ruby/solution.js b/190527/ruby/solution.js new file mode 100644 index 0000000..4c5fba0 --- /dev/null +++ b/190527/ruby/solution.js @@ -0,0 +1,25 @@ +const solution = (answers) => { + let answer = []; + const a = [1,2,3,4,5]; + const b = [2,1,2,3,2,4,2,5]; + const c = [3,3,1,1,2,2,4,4,5,5]; + let num = [0,0,0]; + + answers.forEach((el, i)=>{ + if(el === a[i%5]){ + num[0] = num[0] + 1; + } + if(el === b[i%8]){ + num[1] = num[1] + 1; + } + if(el === c[i%10]){ + num[2] = num[2] + 1; + } + }) + num.forEach( (el, i) => { + if(el === Math.max(...num)){ + answer.push(i+1) + } + }) + return answer +} \ No newline at end of file From 9817182faea9d7d83895e52c91cccb3192198f72 Mon Sep 17 00:00:00 2001 From: LeeJuyeon Date: Tue, 28 May 2019 09:50:16 +0900 Subject: [PATCH 7/7] =?UTF-8?q?ruby=20=EB=AA=A8=EC=9D=98=EA=B3=A0=EC=82=AC?= =?UTF-8?q?=20=ED=92=80=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 190527/ruby/solution.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/190527/ruby/solution.js b/190527/ruby/solution.js index 4c5fba0..6353650 100644 --- a/190527/ruby/solution.js +++ b/190527/ruby/solution.js @@ -20,6 +20,6 @@ const solution = (answers) => { if(el === Math.max(...num)){ answer.push(i+1) } - }) + }) return answer } \ No newline at end of file