From 85f610f2ce29ae0f588fc20e2b875fd5a5700c48 Mon Sep 17 00:00:00 2001 From: Hoyoung Jung Date: Mon, 27 May 2019 16:15:24 +0900 Subject: [PATCH 01/30] [honux] programmers h-index MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 난이도 3점 문제가 좀 이상하다. 분류는 정렬 --- 190524/honux/h-index.js | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 190524/honux/h-index.js diff --git a/190524/honux/h-index.js b/190524/honux/h-index.js new file mode 100644 index 0000000..e3a5572 --- /dev/null +++ b/190524/honux/h-index.js @@ -0,0 +1,6 @@ +function solution(citations) { + citations.sort((a,b) => (b - a)); + let i = 0; + while (i + 1 <= citations[i]) i++; + return i; +} From 891a6c22a3ffe79a0047886f2bd80787c05676c7 Mon Sep 17 00:00:00 2001 From: Hoyoung Jung Date: Thu, 30 May 2019 10:27:53 +0900 Subject: [PATCH 02/30] Add 190530 problem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BOJ 달팽이 --- 190530/problem.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 190530/problem.md diff --git a/190530/problem.md b/190530/problem.md new file mode 100644 index 0000000..35d7125 --- /dev/null +++ b/190530/problem.md @@ -0,0 +1,7 @@ +# 190530 + +## BOJ 1913 달팽이 + +- https://www.acmicpc.net/problem/1913 +- 난이도 2점 + From 0ee56d35669ab6d53407c387582b08dd17e0f890 Mon Sep 17 00:00:00 2001 From: Kong Son Park Date: Mon, 3 Jun 2019 15:40:55 +0900 Subject: [PATCH 03/30] =?UTF-8?q?[=EC=86=8C=EB=8B=88]=20=ED=94=84=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EB=9E=98=EB=A8=B8=EC=8A=A4=20=EB=AA=A8=EC=9D=98?= =?UTF-8?q?=EA=B3=A0=EC=82=AC=20=EC=95=8C=EA=B3=A0=EB=A6=AC=EC=A6=98=20?= =?UTF-8?q?=ED=92=80=EC=9D=B4=20(#45)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 190524 H_index 알고리즘 풀이 * 프로그래머스 알고리즘 모의고사 문제풀이 From 078262089b84fe1c6575c0bc5d2841f2c6012013 Mon Sep 17 00:00:00 2001 From: Minjae Lee <0201.mj.lee@gmail.com> Date: Mon, 3 Jun 2019 15:41:12 +0900 Subject: [PATCH 04/30] =?UTF-8?q?Wangmin=20190530=20=EB=AC=B8=EC=A0=9C?= =?UTF-8?q?=ED=92=80=EC=9D=B4=20(#57)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [Wangmin] 190523 알고리즘 가장 큰 수 풀이 * [wangmin] programmers 42747 H-index -sort * [wangmin] programmers 42840 모의고사 * [wangmin] baek joon 1913 달팽이 --- 190523/wangmin/pg42746.cpp | 28 ++++++++++++++++++++ 190524/wangmin/pg42747.cpp | 21 +++++++++++++++ 190527/wangmin/pg42840.cpp | 49 +++++++++++++++++++++++++++++++++++ 190530/wangmin/bj1913.cpp | 53 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 151 insertions(+) create mode 100644 190523/wangmin/pg42746.cpp create mode 100644 190524/wangmin/pg42747.cpp create mode 100644 190527/wangmin/pg42840.cpp create mode 100644 190530/wangmin/bj1913.cpp diff --git a/190523/wangmin/pg42746.cpp b/190523/wangmin/pg42746.cpp new file mode 100644 index 0000000..2fbd7a5 --- /dev/null +++ b/190523/wangmin/pg42746.cpp @@ -0,0 +1,28 @@ +#include +#include +#include +#include + +using namespace std; + +bool func(string a, string b){ + return a+b > b+a ? true : false; +} + +string solution(vector numbers) { + string answer = ""; + vector str; + for(int i = 0 ; i < numbers.size(); i++){ + str.push_back(to_string(numbers[i])); + } + + sort(str.begin(), str.end(), func); + for(int i = 0; i < str.size(); i++){ + answer += str[i]; + } + if(answer[0] == '0'){ + return "0"; + } + + return answer; +} \ No newline at end of file diff --git a/190524/wangmin/pg42747.cpp b/190524/wangmin/pg42747.cpp new file mode 100644 index 0000000..8d1425a --- /dev/null +++ b/190524/wangmin/pg42747.cpp @@ -0,0 +1,21 @@ +#include +#include +#include +#include + +using namespace std; + +int solution(vector citations) { + int h; + sort(citations.begin(),citations.end()); + for(int i = 0; i< citations.size(); i++){ + h = citations.size()-i; + + if(citations[i] >= h){ + return h; + } + + } + return 0; +} + diff --git a/190527/wangmin/pg42840.cpp b/190527/wangmin/pg42840.cpp new file mode 100644 index 0000000..941df3c --- /dev/null +++ b/190527/wangmin/pg42840.cpp @@ -0,0 +1,49 @@ +#include +#include +#include + +using namespace std; + +vector solution(vector answers) { + vector one = {1,2,3,4,5}; + vector two = {2,1,2,3,2,4,2,5}; + vector three = {3,3,1,1,2,2,4,4,5,5}; + + int oneCount = 0; + int twoCount = 0; + int threeCount = 0; + + for(int i = 0; i < answers.size(); i++){ + if(answers[i] == one[i%one.size()]){ + oneCount++; + } + } + + int max = oneCount; + + for(int i = 0; i < answers.size(); i++){ + if(answers[i] == two[i%two.size()]){ + twoCount++; + } + } + + max = (twoCount > max) ? twoCount : max; + + for(int i = 0; i < answers.size(); i++){ + if(answers[i] == three[i%three.size()]){ + threeCount++; + } + } + + max = (threeCount > max) ? threeCount : max; + + + + vector answer; + if(max == oneCount) answer.push_back(1); + if(max == twoCount) answer.push_back(2); + if(max == threeCount) answer.push_back(3); + + + return answer; +} \ No newline at end of file diff --git a/190530/wangmin/bj1913.cpp b/190530/wangmin/bj1913.cpp new file mode 100644 index 0000000..af70292 --- /dev/null +++ b/190530/wangmin/bj1913.cpp @@ -0,0 +1,53 @@ +//https://www.acmicpc.net/problem/1913 + +#include +#include + +using namespace std; + +int main () { + int n,a; + cin >> n >> a; + + vector> vec = vector>(n,(vector(n,0))); + + vector start ={n/2,n/2}; + vector> right = {{-1,0},{0,1},{1,0},{0,-1}}; + vector head = {-1,0}; + + vector aindex = {0,0}; + + // vec[start[0]][start[1]] = 1; + int rightindex = 0; + for(int i = 1; i <= n*n; i ++){ + // vec[start[0],start[1]] + vec[start[0]][start[1]] = i; + + if(i == a){ + aindex = {start[0],start[1]}; + } + + if(vec[start[0]+right[rightindex%4][0]][start[1]+right[rightindex%4][1]] == 0){ + head = right[rightindex%4]; + start[0] = start[0]+head[0]; + start[1] = start[1]+head[1]; + rightindex++; + }else{ + start[0] = start[0]+head[0]; + start[1] = start[1]+head[1]; + } + } + + for(int i = 0; i < n; i++){ + for(int j = 0; j < n; j++){ + cout << vec[i][j]<<" "; + } + cout << "\n"; + } + + cout << aindex[0]+1 << " " << aindex[1]+1< Date: Mon, 3 Jun 2019 15:41:37 +0900 Subject: [PATCH 05/30] Su (#46) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add 190521 problem 프로그래머스 k번째수 * k번째 수 * h번째 인덱스 * mockExam algorithm --- 190527/mockExam.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 190527/mockExam.js diff --git a/190527/mockExam.js b/190527/mockExam.js new file mode 100644 index 0000000..9f3ea56 --- /dev/null +++ b/190527/mockExam.js @@ -0,0 +1,21 @@ +function solution(answers) { + let answer = []; + let supo1 = [1,2,3,4,5]; + let supo2 = [2,1,2,3,2,4,2,5]; + let supo3 = [3,3,1,1,2,2,4,4,5,5]; + let ans1 = howManyCorrect(answers , supo1); + let ans2 = howManyCorrect(answers , supo2); + let ans3 = howManyCorrect(answers , supo3); + let max = Math.max(ans1,ans2,ans3); + if( max === ans1) answer.push(1); + if( max === ans2) answer.push(2); + if( max === ans3) answer.push(3); + + return answer; +} + +function howManyCorrect(ans , supo) { + return ans.filter(function(v, i){ + return v === supo[i % supo.length]; + }).length +} From 8a125d3421de96ba54714e5e02af5f048f309f26 Mon Sep 17 00:00:00 2001 From: jeuk817 <47104203+jeuk817@users.noreply.github.com> Date: Mon, 3 Jun 2019 15:41:55 +0900 Subject: [PATCH 06/30] =?UTF-8?q?feat:=20H=20index,=20=EB=AA=A8=EC=9D=98?= =?UTF-8?q?=EA=B3=A0=EC=82=AC=20=ED=92=80=EC=9D=B4=20(#47)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 190524/circus/hIndex.js | 34 ++++++++++++++++++++++++++++++++++ 190527/circus/exam.js | 19 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 190524/circus/hIndex.js create mode 100644 190527/circus/exam.js diff --git a/190524/circus/hIndex.js b/190524/circus/hIndex.js new file mode 100644 index 0000000..d507e9f --- /dev/null +++ b/190524/circus/hIndex.js @@ -0,0 +1,34 @@ +// 첫번째 +function solution(citations) { + var answer = 0; + while (true) { + if (citations.filter(x => { return x > answer }).length > answer) { + answer += 1; + continue; + } + break; + } + return Math.max.apply(null, citations) === 0 ? 0 : answer; +} + +// 두번째 + +function solution(citations) { + citations.sort((a, b) => b - a).unshift(0); + for (var i = citations.length - 1; i >= 0; i--) { + if (citations[i] >= i) return i; + } +} + +// 세번째 + +function solution(citations) { + citations = citations.sort((a, b) => a - b); + while (true) { + if (citations.findIndex(x => x < citations.length) !== -1) { + citations.shift(); + } else { + return citations.length; + } + } +} \ No newline at end of file diff --git a/190527/circus/exam.js b/190527/circus/exam.js new file mode 100644 index 0000000..a5cac56 --- /dev/null +++ b/190527/circus/exam.js @@ -0,0 +1,19 @@ +function solution(answers) { + var num1 = [1, 2, 3, 4, 5]; + var num2 = [2, 1, 2, 3, 2, 4, 2, 5]; + var num3 = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5]; + var results = [0, 0, 0]; + var winer = []; + + answers.forEach((ans, i) => { + if (ans === num1[i % num1.length]) results[0] += 1; + if (ans === num2[i % num2.length]) results[1] += 1; + if (ans === num3[i % num3.length]) results[2] += 1; + }) + + var max = Math.max(...results); + results.forEach((result, i) => { + if (result === max) winer.push(i + 1); + }) + return winer; +} \ No newline at end of file From 008cc1861be5ad82d8091c2ebe51e7a9e13f8fa4 Mon Sep 17 00:00:00 2001 From: gminiy Date: Mon, 3 Jun 2019 15:42:10 +0900 Subject: [PATCH 07/30] [ingleby]190527 algorithm (#48) --- 190527/ingleby/mouigosa.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 190527/ingleby/mouigosa.py diff --git a/190527/ingleby/mouigosa.py b/190527/ingleby/mouigosa.py new file mode 100644 index 0000000..bb4a765 --- /dev/null +++ b/190527/ingleby/mouigosa.py @@ -0,0 +1,24 @@ +def solution(answers): + patternA = [1, 2, 3, 4, 5] + patternB = [2, 1, 2, 3, 2, 4, 2, 5] + patternC = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5] + i = 0 + a = 0 + b = 0 + c = 0 + for s in answers : + if patternA[i%5] == s: + a=a+1 + if patternB[i%8] == s: + b=b+1 + if patternC[i%10] == s: + c=c+1 + i = i+1 + answer2 = [a,b,c] + maxt = max(answer2) + answer = [] + i = 1 + for idx in range(len(answer2)): + if answer2[idx] == maxt: + answer.append(idx + 1) + return answer From 291a605b4a9760f6743811b56581503fd1e98ff1 Mon Sep 17 00:00:00 2001 From: SangYun Ha Date: Mon, 3 Jun 2019 15:42:31 +0900 Subject: [PATCH 08/30] =?UTF-8?q?[190527]=20H=20=EC=95=8C=EA=B3=A0?= =?UTF-8?q?=EB=A6=AC=EC=A6=98=20=EB=AC=B8=EC=A0=9C=ED=92=80=EC=9D=B4=20?= =?UTF-8?q?=EC=A0=9C=EC=B6=9C=ED=95=A9=EB=8B=88=EB=8B=A4.=20(#49)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * H-Index 문제풀이 * H-Index 문제풀이 * 모의고사 문제풀이 --- 190527/H/exam.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 190527/H/exam.py diff --git a/190527/H/exam.py b/190527/H/exam.py new file mode 100644 index 0000000..9fd5582 --- /dev/null +++ b/190527/H/exam.py @@ -0,0 +1,17 @@ +def solution(answers): + person1 = [1, 2, 3, 4, 5] + person2 = [2, 1, 2, 3, 2, 4, 2, 5] + person3 = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5] + count = [0, 0, 0] + result = [] + for idx, answer in enumerate(answers): + if answer == person1[idx % len(person1)]: + count[0] += 1 + if answer == person2[idx % len(person2)]: + count[1] += 1 + if answer == person3[idx % len(person3)]: + count[2] += 1 + for idx, c in enumerate(count): + if c == max(count): + result.append(idx+1) + return result From aba78191206b9435bfe813f9e5c08584931f00a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=AC=B5=EC=9D=80=EC=A7=80?= <39726860+mukeunzi@users.noreply.github.com> Date: Mon, 3 Jun 2019 15:42:42 +0900 Subject: [PATCH 09/30] =?UTF-8?q?[mukeunzi]=20190528=20=EB=AA=A8=EC=9D=98?= =?UTF-8?q?=EA=B3=A0=EC=82=AC=20=EC=95=8C=EA=B3=A0=EB=A6=AC=EC=A6=98=20?= =?UTF-8?q?=EB=AC=B8=EC=A0=9C=ED=92=80=EC=9D=B4=20(#50)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 190527/mukeunzi/MockTest.java | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 190527/mukeunzi/MockTest.java diff --git a/190527/mukeunzi/MockTest.java b/190527/mukeunzi/MockTest.java new file mode 100644 index 0000000..e49f252 --- /dev/null +++ b/190527/mukeunzi/MockTest.java @@ -0,0 +1,46 @@ +import java.util.*; + +class Solution { + public int[] solution(int[] answers) { + int way1[] = new int[]{1, 2, 3, 4, 5}; + int way2[] = new int[]{2, 1, 2, 3, 2, 4, 2, 5}; + int way3[] = new int[]{3, 3, 1, 1, 2, 2, 4, 4, 5, 5}; + int cnt[] = new int[3]; + int max = 0; + int result[]; + List answer = new ArrayList<>(); + + for(int i=0; i Date: Mon, 3 Jun 2019 15:43:06 +0900 Subject: [PATCH 10/30] =?UTF-8?q?[ruby]=20=EB=AA=A8=EC=9D=98=EA=B3=A0?= =?UTF-8?q?=EC=82=AC=20=EB=B3=B4=EB=83=85=EB=8B=88=EB=8B=A4.=20(#52)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * programmers runner * programmers runner * k번째 수 문제풀이 -map 사용해서 slice 로 answer 에 push * refactor : map 중복제거 * h-index solution * ruby 모의고사 문제풀이 * ruby 모의고사 풀이 --- 190521/k_number.js | 6 ------ 190524/ruby/solution.js | 13 +++++++++++++ 190527/ruby/solution.js | 25 +++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 6 deletions(-) delete mode 100644 190521/k_number.js create mode 100644 190524/ruby/solution.js create mode 100644 190527/ruby/solution.js diff --git a/190521/k_number.js b/190521/k_number.js deleted file mode 100644 index d49891a..0000000 --- a/190521/k_number.js +++ /dev/null @@ -1,6 +0,0 @@ -const solution = (arr, commands) => { - let answer = commands.map( el => arr.slice(el[0]-1,el[1]).sort(sortFuc)[el[2]-1]) - return answer; -} - -const sortFuc = (a,b) => {return a-b}; \ No newline at end of file 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 diff --git a/190527/ruby/solution.js b/190527/ruby/solution.js new file mode 100644 index 0000000..6353650 --- /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 380f6d3295165572ceb2dd812ff2bb435a482d4f Mon Sep 17 00:00:00 2001 From: nailerHeum Date: Mon, 3 Jun 2019 15:43:23 +0900 Subject: [PATCH 11/30] Nailer Solve programmers supoja problem (#53) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Solve programmers supoja problem https://programmers.co.kr/learn/courses/30/lessons/42840 * Solve snail problem 백준 달팽이 알고리즘 문제 해결 --- 190527/nailer/supoja.py | 31 +++++++++++++++++++++++++++++++ 190530/nailer/snail.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 190527/nailer/supoja.py create mode 100644 190530/nailer/snail.py diff --git a/190527/nailer/supoja.py b/190527/nailer/supoja.py new file mode 100644 index 0000000..4da95b0 --- /dev/null +++ b/190527/nailer/supoja.py @@ -0,0 +1,31 @@ +def solution(answers): + answer = [] + x = 0 + y = 0 + z = 0 + d = {} + ySet = [2, 1, 2, 3, 2, 4, 2, 5] + zSet = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5] + for i in list(range(len(answers))): + if answers[i] == i % 5 + 1: + x += 1 + if answers[i] == ySet[i % 8]: + y += 1 + if answers[i] == zSet[i % 10]: + z += 1 + if x==y and y==z: + return [1,2,3] + if x>y and x>z: + return [1] + if y>x and y>z: + return [2] + if z>x and z>y: + return [3] + if x==y and y > z: + return [1, 2] + if y==z and z > x: + return [2, 3] + if z==x and x > y: + return [1, 3] + + return answer diff --git a/190530/nailer/snail.py b/190530/nailer/snail.py new file mode 100644 index 0000000..24e3901 --- /dev/null +++ b/190530/nailer/snail.py @@ -0,0 +1,32 @@ +import sys +from functools import reduce + +a = int(input()) +b = int(input()) +matrix = [[0]*a for i in range(a)] +row = a//2 +column = a//2 +sequence = 1 +sequenceCount = 0 +posiNeg = -1 +answerRow = 0 +answerCol = 0 + +for i in range(a*a): + matrix[row][column] = i+1 + if b == i+1: + answerRow = row + answerCol = column + if sequenceCount == 2*sequence: + sequence += 1 + sequenceCount = 0 + posiNeg *= -1 + sequenceCount += 1 + if sequenceCount <= sequence: + row += posiNeg + else: + column += posiNeg * -1 + +for item in matrix: + print(reduce(lambda x, y: str(x)+' '+str(y), item)) +print(answerRow+1, answerCol+1) From d314a086cd0deec984a4a42ac82c3b8046ec95fc Mon Sep 17 00:00:00 2001 From: Jake Date: Mon, 3 Jun 2019 15:43:49 +0900 Subject: [PATCH 12/30] =?UTF-8?q?[Jake]=20190530=20=EB=8B=AC=ED=8C=BD?= =?UTF-8?q?=EC=9D=B4=20=EC=95=8C=EA=B3=A0=EB=A6=AC=EC=A6=98=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=ED=92=80=EC=9D=B4=20(#54)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 19년 5월 21일 PS 솔루션 업데이트 프로그래머스 - K번째 수 * fix: 솔루션 파일 이동 * feat: 19년 5월 22일 PS 솔루션 업데이트 프로그래머스 - 가장 큰 수 * feat: 19년 5월 24일 PS 솔루션 업데이트 프로그래머스 - H-index * fix: H-Index 수정 나머지 논문의 포함 범위를 수정(인용 횟수가 h번 미만) * feat: 19년 5월 27일 PS 솔루션 업데이트 프로그래머스 - 모의고사 * feat: 19년 5월 30일 PS 솔루션 업데이트 백준 - 달팽이 --- 190530/jake/1913.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 190530/jake/1913.cpp diff --git a/190530/jake/1913.cpp b/190530/jake/1913.cpp new file mode 100644 index 0000000..bd8beca --- /dev/null +++ b/190530/jake/1913.cpp @@ -0,0 +1,39 @@ +#include +using namespace std; +int n, t; +int arr[999][999]{0,}; + +int dir[4][2] = {1, 0, 0, 1, -1, 0, 0, -1}; + +bool valid_location(int y, int x) +{ + return y < n && y >= 0 && x < n && x >= 0 && arr[y][x] == 0; +} + +int main() { + ios::sync_with_stdio(false); + cin.tie(NULL); + + cin >> n >> t; + + int num = n * n, d = 0, y = -1, x = 0, ay, ax; + + while(num > 0){ + int dy = dir[d % 4][0], dx = dir[d % 4][1]; + y += dy, x += dx; + while(valid_location(y, x)){ + if(num == t) ay = y, ax = x; + arr[y][x] = num--, y += dy, x += dx; + } + y -= dy, x -= dx; + ++d; + } + + for(int i=0; i Date: Mon, 3 Jun 2019 15:44:08 +0900 Subject: [PATCH 13/30] =?UTF-8?q?=ED=94=84=EB=A1=9C=EA=B7=B8=EB=9E=98?= =?UTF-8?q?=EB=A8=B8=EC=8A=A4=20-=20=20=EB=AA=A8=EC=9D=98=EA=B3=A0?= =?UTF-8?q?=EC=82=AC=20=EB=AC=B8=EC=A0=9C=20=ED=92=80=EC=9D=B4=20(#56)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 190527/hyodol/mock_test.cpp | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 190527/hyodol/mock_test.cpp diff --git a/190527/hyodol/mock_test.cpp b/190527/hyodol/mock_test.cpp new file mode 100644 index 0000000..4d6c8d5 --- /dev/null +++ b/190527/hyodol/mock_test.cpp @@ -0,0 +1,43 @@ +#include +#include +using namespace std; + +vector solution(vector answers) { + vector > patterns(3); + patterns[0] = {1, 2, 3, 4, 5}; + patterns[1] = {2, 1, 2, 3, 2, 4, 2, 5}; + patterns[2] = {3, 3, 1, 1, 2, 2, 4, 4, 5, 5}; + + int maxCnt = 0; + vector personCnt(3); + for (int i = 0; i < 3; i++) { + int cnt = 0; + int patternsSize = (int)patterns[i].size(); + for (int j = 0; j < answers.size(); j++) { + if (answers[j] == patterns[i][j % patternsSize]) cnt++; + } + personCnt[i] = cnt; + maxCnt = max(maxCnt, cnt); + } + + vector result; + for (int i = 0; i < 3; i++) { + if (maxCnt == personCnt[i]) result.push_back(i+1); + } + return result; +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(0); + + vector result1 = solution({1, 2, 3, 4, 5}); + for (int num : result1) cout << num << " "; + cout << '\n'; + + vector result2 = solution({1, 3, 2, 4, 2}); + for (int num : result2) cout << num << " "; + cout << '\n'; + + return 0; +} From 7ac73a69acd4c1032dc5938f1982c4df775a5ce6 Mon Sep 17 00:00:00 2001 From: Hoyoung Jung Date: Mon, 3 Jun 2019 15:48:44 +0900 Subject: [PATCH 14/30] BOJ 1913 snail (#60) --- 190530/honux/1913-snail.cpp | 56 +++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 190530/honux/1913-snail.cpp diff --git a/190530/honux/1913-snail.cpp b/190530/honux/1913-snail.cpp new file mode 100644 index 0000000..9983edf --- /dev/null +++ b/190530/honux/1913-snail.cpp @@ -0,0 +1,56 @@ +#include +#include +#include +#include +#include + +using namespace std; +int dr[] = { -1, 0, 1, 0 }; +int dc[] = { 0, 1, 0, -1 }; + + +int main() { + int n; + scanf("%d", &n); + vector > m(n); + map> nmap; + for (int i = 0; i < n; i++) { + m[i].resize(n); + } + + int num = 1; + int row = n / 2; + int col = row; + double w = 1; + m[row][col] = num; + int vec = 0; + + bool loop = true; + while (loop) { + for (int i = 0; i < (int) w; i++) { + num++; + if (num > n * n) { + loop = false; + break; + } + row += dr[vec]; + col += dc[vec]; + m[row][col] = num; + nmap[num] = make_pair(row + 1, col + 1); + } + vec = (vec + 1) % 4; + w += 0.5; + } + + for (auto v : m) { + for (auto n : v) { + printf("%d ", n); + } + printf("\n"); + } + + int x; + scanf("%d", &x); + printf("%d %d\n", nmap[x].first, nmap[x].second); + return 0; +} From 8dfe3358706647d631d324bebd763507abc91156 Mon Sep 17 00:00:00 2001 From: JangHyoSeok Date: Mon, 10 Jun 2019 16:07:11 +0900 Subject: [PATCH 15/30] =?UTF-8?q?=EB=8B=AC=ED=8C=BD=EC=9D=B4=20(#62)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 190530/hyodol/snail.cpp | 54 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 190530/hyodol/snail.cpp diff --git a/190530/hyodol/snail.cpp b/190530/hyodol/snail.cpp new file mode 100644 index 0000000..ba72ec3 --- /dev/null +++ b/190530/hyodol/snail.cpp @@ -0,0 +1,54 @@ +// BOJ 1913 - 달팽이 +#include +#include +using namespace std; + +const int dy[] = {-1, 0, 1, 0}; +const int dx[] = {0, 1, 0, -1}; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(0); + + int n; + cin >> n; + vector > arr(n, vector(n)); + + int value; + cin >> value; + + int num = 1; + int dir = 0; + int y = n / 2; + int x = n / 2; + while (!(y == 0 && x == 0)) { + arr[y][x] = num++; + int ny = y + dy[dir % 4]; + int nx = x + dx[dir % 4]; + if (ny < 0 || ny >= n || nx < 0 || nx >= n) dir++; + if (arr[ny][nx] == 0) { + y = ny; + x = nx; + dir++; + } else { + dir--; + num--; + } + } + arr[y][x] = num; + + int findY = 0, findX = 0; + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + if (value == arr[i][j]) { + findY = i+1; + findX = j+1; + } + cout << arr[i][j] << " "; + } + cout << '\n'; + } + + cout << findY << " " << findX << '\n'; + return 0; +} From 8dd49df4a317dd07235c00d93caa2a5a54b5e96b Mon Sep 17 00:00:00 2001 From: Hoyoung Jung Date: Tue, 11 Jun 2019 17:30:43 +0900 Subject: [PATCH 16/30] Honux (#63) * BOJ 1913 snail * Update 190611 problem --- 190611/problem.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 190611/problem.md diff --git a/190611/problem.md b/190611/problem.md new file mode 100644 index 0000000..07c8f5c --- /dev/null +++ b/190611/problem.md @@ -0,0 +1,6 @@ +# 소수 찾기 + +- https://programmers.co.kr/learn/courses/30/lessons/42839 +- 분류: 완전탐색 +- 난이도: 2 + From cc9b7a1f7590523dfd4bcccf02bfba1e67c3b808 Mon Sep 17 00:00:00 2001 From: Kong Son Park Date: Wed, 12 Jun 2019 12:44:15 +0900 Subject: [PATCH 17/30] [sony] algorithm, programmers findPrimeNumber (#65) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 프로그래머스 소수 찾기 문제 풀이 --- 190611/sony/Lv2_findPrimeNum.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 190611/sony/Lv2_findPrimeNum.py diff --git a/190611/sony/Lv2_findPrimeNum.py b/190611/sony/Lv2_findPrimeNum.py new file mode 100644 index 0000000..76c92b2 --- /dev/null +++ b/190611/sony/Lv2_findPrimeNum.py @@ -0,0 +1,33 @@ +import itertools + +def primNumber(n): + if n < 2: return False + if n == 2: return True + if n % 2 == 0: return False + + m = int(n**0.5)+1 + + for i in range(3,m,2): + if n % i == 0: + return False + return True + +def findPrimeNum(numbers): + count = 0 + a = set() + for k in range(len(numbers)): + n = list(itertools.permutations(numbers, k+1)) + + for i in n: + s = ''.join(i) + a.add(int(s)) + + for j in a: + if primNumber(j): + count += 1 + return count + +# nums = '17' +nums = '011' + +findPrimeNum(nums) \ No newline at end of file From 12e3a6dc2b45d349190f4b4a0f79130f5002f89f Mon Sep 17 00:00:00 2001 From: Jake Date: Wed, 12 Jun 2019 17:25:37 +0900 Subject: [PATCH 18/30] =?UTF-8?q?feat:=2019=EB=85=84=206=EC=9B=94=2012?= =?UTF-8?q?=EC=9D=BC=20PS=20=EC=86=94=EB=A3=A8=EC=85=98=20=EC=97=85?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=8A=B8=20(#67)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 프로그래머스 - 소수 찾기(Level2, 완전탐색) --- 190611/jake/find-primes.cpp | 49 +++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 190611/jake/find-primes.cpp diff --git a/190611/jake/find-primes.cpp b/190611/jake/find-primes.cpp new file mode 100644 index 0000000..792de56 --- /dev/null +++ b/190611/jake/find-primes.cpp @@ -0,0 +1,49 @@ +#include +using namespace std; +unordered_set used; +vector picked; + +bool check_prime(const int n) +{ + if(n == 2) return true; + if(n == 1 || n % 2 == 0) return false; + + int sqrt_root = 1; + while(sqrt_root * sqrt_root < n * n) + ++sqrt_root; + + for(int i=2; i& digits, int number, int len) +{ + if(len == digits.size()) return 0; + + int ret = 0; + for(int i=0; i digits; + for(char c : numbers) digits.push_back(c - '0'); + picked = vector(digits.size(), false); + + return check_all_numbers(digits, 0, 0); +} From 65677ac7db532313f0a6bbed258b5f821b1ceebf Mon Sep 17 00:00:00 2001 From: JangHyoSeok Date: Wed, 12 Jun 2019 17:25:55 +0900 Subject: [PATCH 19/30] =?UTF-8?q?[Programmers=20-=2042839]=20=EC=86=8C?= =?UTF-8?q?=EC=88=98=20=EC=B0=BE=EA=B8=B0=20=EB=AC=B8=EC=A0=9C=20=ED=92=80?= =?UTF-8?q?=EC=9D=B4=20(#66)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 190611/hyodol/find_prime_number.cpp | 51 +++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 190611/hyodol/find_prime_number.cpp diff --git a/190611/hyodol/find_prime_number.cpp b/190611/hyodol/find_prime_number.cpp new file mode 100644 index 0000000..aaf21a4 --- /dev/null +++ b/190611/hyodol/find_prime_number.cpp @@ -0,0 +1,51 @@ +// 완전 탐색 - 순열 알고리즘으로 구현 +// 소수는 에라토스테네스의 체로 미리 구한다. +// 중복되는 숫자는 set 컨테이너로 체크하기 +#include +#include +#include +#include +#include +#include +using namespace std; + +vector getPrime() { + const int MAX = 9999999; + vector isPrime(MAX+1, true); + isPrime[0] = isPrime[1] = false; + for (int i = 2; i < sqrt(MAX); i++) { + if (!isPrime[i]) continue; + for (int j = i*i; j <= MAX; j+=i) { + isPrime[j] = false; + } + } + return isPrime; +} + +int solution(string numbers) { + string tempNumbers = numbers; + sort(tempNumbers.begin(), tempNumbers.end()); + vector isPrime = getPrime(); + set checkPrime; + do { + for (int d = 1; d <= numbers.length(); d++) { + int num = stoi(tempNumbers.substr(0, d)); + if (isPrime[num] && checkPrime.count(num) == 0) { + checkPrime.insert(num); + } + } + } while (next_permutation(tempNumbers.begin(), tempNumbers.end())); + + return (int)checkPrime.size(); +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(0); + + cout << solution("17") << '\n'; + cout << solution("011") << '\n'; + cout << solution("012") << '\n'; + + return 0; +} From e0e1e691233e50a250845a6ee5e958f1c9573d09 Mon Sep 17 00:00:00 2001 From: Hoyoung Jung Date: Thu, 13 Jun 2019 14:22:47 +0900 Subject: [PATCH 20/30] Honux (#68) * BOJ 1913 snail * Update 190611 problem * Update problem 109613 BOJ O(n) sort --- 190613/problem.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 190613/problem.md diff --git a/190613/problem.md b/190613/problem.md new file mode 100644 index 0000000..cb8892d --- /dev/null +++ b/190613/problem.md @@ -0,0 +1,5 @@ +# BOJ 정렬하기 3 + +- https://www.acmicpc.net/problem/10989 +- 난이도: 2점 + From 97db8c444cfe5f67c230089a9dafefcf2185d633 Mon Sep 17 00:00:00 2001 From: Jake Date: Sat, 15 Jun 2019 14:56:40 +0900 Subject: [PATCH 21/30] =?UTF-8?q?feat:=2019=EB=85=84=206=EC=9B=94=2013?= =?UTF-8?q?=EC=9D=BC=20PS=20=EC=86=94=EB=A3=A8=EC=85=98=20=EC=97=85?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=8A=B8=20(#69)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 백준 - 수 정렬하기 3(counting sort) --- 190613/jake/10989.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 190613/jake/10989.cpp diff --git a/190613/jake/10989.cpp b/190613/jake/10989.cpp new file mode 100644 index 0000000..40149f0 --- /dev/null +++ b/190613/jake/10989.cpp @@ -0,0 +1,22 @@ +#include +using namespace std; +int N; +int store[10001] {0,}; +int main() +{ + ios_base::sync_with_stdio(false); + cin.tie(NULL); + cin >> N; + int t; + while(N--){ + cin >> t; + store[t]++; + } + for(int i = 1; i < 10001; ++i){ + while(store[i]--){ + cout << i << "\n"; + } + } + return 0; +} + From 5200d07268d4dcf523fbf41e9f828337996e73ba Mon Sep 17 00:00:00 2001 From: JangHyoSeok Date: Sat, 15 Jun 2019 14:56:53 +0900 Subject: [PATCH 22/30] =?UTF-8?q?=EC=88=98=20=EC=A0=95=EB=A0=AC=ED=95=98?= =?UTF-8?q?=EA=B8=B03=20(#70)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 190613/hyodol/10989.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 190613/hyodol/10989.cpp diff --git a/190613/hyodol/10989.cpp b/190613/hyodol/10989.cpp new file mode 100644 index 0000000..7fac9ee --- /dev/null +++ b/190613/hyodol/10989.cpp @@ -0,0 +1,29 @@ +// BOJ 10989 - 수 정렬하기 3 +// Counting Sort +#include +#include +#include +using namespace std; +const int MAX = 10000; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(0); + + int n; + cin >> n; + + vector count(MAX+1); + for (int i = 0; i < n; i++) { + int num; + cin >> num; + count[num]++; + } + + for (int num = 0; num <= MAX; num++) { + if (count[num] == 0) continue; + while (count[num]--) cout << num << '\n'; + } + + return 0; +} From 1d384c870d81e8cd6b9f5ae83b722d07fe27311a Mon Sep 17 00:00:00 2001 From: Kong Son Park Date: Sat, 15 Jun 2019 14:57:03 +0900 Subject: [PATCH 23/30] [Sony] BOJ algorithm 10989 (#71) - Counting sort --- 190613/sony/boj_10989.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 190613/sony/boj_10989.py diff --git a/190613/sony/boj_10989.py b/190613/sony/boj_10989.py new file mode 100644 index 0000000..057b00e --- /dev/null +++ b/190613/sony/boj_10989.py @@ -0,0 +1,17 @@ +import sys + +n = int(sys.stdin.readline()) + + +def countingSort(n): + count_list = [0] * (10001) # 주어지는 수의 크기 범위만큼 리스트 길이를 만든다. + for _ in range(n): + a = int(sys.stdin.readline()) + count_list[a] += 1 + + for j in range(len(count_list)): + if count_list[j] != 0: + for _ in range(count_list[j]): + print(j) + +countingSort(n) From b056159ec18947a4b6f52673a2418b9c377e6ebf Mon Sep 17 00:00:00 2001 From: Hoyoung Jung Date: Sat, 15 Jun 2019 16:05:56 +0900 Subject: [PATCH 24/30] Honux (#72) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fail to solve find prime 프로그래머스 문제 풀다 실패 순열로 구했는데 조합이었다. 내일 하자. * Solve programmers find prime 복잡하다... 여튼 풀긴 풀었네. * Add problem 문제 추가 --- 190611/190617/problem.md | 4 ++++ 190611/honux/test.js | 21 +++++++++++++++++ 190611/honux/test2.js | 22 ++++++++++++++++++ 190611/honux/try1.js | 43 ++++++++++++++++++++++++++++++++++ 190611/honux/try2.js | 50 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 140 insertions(+) create mode 100644 190611/190617/problem.md create mode 100644 190611/honux/test.js create mode 100644 190611/honux/test2.js create mode 100644 190611/honux/try1.js create mode 100644 190611/honux/try2.js diff --git a/190611/190617/problem.md b/190611/190617/problem.md new file mode 100644 index 0000000..1ba81b0 --- /dev/null +++ b/190611/190617/problem.md @@ -0,0 +1,4 @@ +# programmers 타겟 넘버 + +- https://programmers.co.kr/learn/courses/30/lessons/43165 + diff --git a/190611/honux/test.js b/190611/honux/test.js new file mode 100644 index 0000000..cdad665 --- /dev/null +++ b/190611/honux/test.js @@ -0,0 +1,21 @@ +let arr = [1,2,3,4]; + +function swap(arr, i, j) { + const temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; +} + +function all(arr, n) { + if (n == arr.length - 1) { + console.log(arr); + } + for (let i = n; i < arr.length ; i++) { + swap(arr, n, i); + all(arr, n + 1); + swap(arr, n, i); + } +} + +all(arr, 0); + diff --git a/190611/honux/test2.js b/190611/honux/test2.js new file mode 100644 index 0000000..c2aa652 --- /dev/null +++ b/190611/honux/test2.js @@ -0,0 +1,22 @@ +function swap(arr, i, j) { + const temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; +} + +function perm(arr, k, j = 0) { + if (j === k){ + console.log(arr.slice(0,j)); + return; + } + for (let i = j; i < arr.length; i++) { + swap(arr, i, j); + perm(arr, k, j + 1); + swap(arr, i, j); + } +} + +arr = [1, 2, 3]; +perm(arr, 1); +console.log("=========="); +perm(arr, 2); diff --git a/190611/honux/try1.js b/190611/honux/try1.js new file mode 100644 index 0000000..fac5e1a --- /dev/null +++ b/190611/honux/try1.js @@ -0,0 +1,43 @@ +const prime = [] +const maxn = 9999999; +let count = 0; + +for (let i = 0; i <= maxn; i++) { + prime.push(true); +} +prime[0] = prime[1] = false; + +for (let i = 2; i<= maxn; i++) { + if(!prime[i]) continue; + for (let j = i * 2; j <= maxn; j += i) { + prime[j] = false; + } +} + +function swap(arr, i, j) { + const temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; +} + +function genNum(arr, i) { + if (i == arr.length - 1) { + const n = Number(arr.join("")); + console.log(n); + if (prime[n]) count++; + return; + } + for (let j = i; j < arr.length; j++) { + swap(arr, i, j); + genNum(arr, i + 1); + swap(arr, i, j); + } +} + +function solution(numbers) { + count = 0; + let a = numbers.split(""); + console.log(a); + genNum(a, 0); + return count; +} diff --git a/190611/honux/try2.js b/190611/honux/try2.js new file mode 100644 index 0000000..e9e278d --- /dev/null +++ b/190611/honux/try2.js @@ -0,0 +1,50 @@ +const prime = [] +const maxn = 9999999; +let count = 0; + +for (let i = 0; i <= maxn; i++) { + prime.push(true); +} +prime[0] = prime[1] = false; + +for (let i = 2; i<= maxn; i++) { + if(!prime[i]) continue; + for (let j = i * 2; j <= maxn; j += i) { + prime[j] = false; + } +} + +function swap(arr, i, j) { + const temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; +} + +function perm(arr, k, j = 0) { + if (j === k){ + const n = Number(arr.slice(0, j).join("")); + console.log(n); + //count only once + if (prime[n]) { + count++; + prime[n] = false; + } + return; + } + for (let i = j; i < arr.length; i++) { + swap(arr, i, j); + perm(arr, k, j + 1); + swap(arr, i, j); + } +} + +function solution(numbers) { + count = 0; + let a = numbers.split(""); + for (let i = 1; i <= numbers.length; i++) { + perm(a, i); + } + return count; +} + +console.log(solution("17")); From ae36b7b17958f8c2f01417f4f82dbe8d7e582bed Mon Sep 17 00:00:00 2001 From: SangYun Ha Date: Sun, 16 Jun 2019 11:41:18 +0900 Subject: [PATCH 25/30] =?UTF-8?q?[H]=20=EC=86=8C=EC=88=98=EC=B0=BE?= =?UTF-8?q?=EA=B8=B0=20=EB=AC=B8=EC=A0=9C=ED=92=80=EC=9D=B4=20=EC=A0=9C?= =?UTF-8?q?=EC=B6=9C=ED=95=A9=EB=8B=88=EB=8B=A4.=20(#73)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * H-Index 문제풀이 * H-Index 문제풀이 * 소수 찾기 문제풀이 --- 190611/H/count_prime_number.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 190611/H/count_prime_number.py diff --git a/190611/H/count_prime_number.py b/190611/H/count_prime_number.py new file mode 100644 index 0000000..dae7eea --- /dev/null +++ b/190611/H/count_prime_number.py @@ -0,0 +1,31 @@ +from itertools import permutations + + +def makeNumbers(numbers): + numbers = list(numbers) + resultA = [] + for i in range(1, len(numbers)+1): + resultA.append(permutations(numbers, i)) + resultB = [y for x in resultA for y in x] + answer = set([str(int(''.join(j))) for j in resultB]) + return answer + + +def countPrimeNumber(numberlist): + answer = 0 + for i in numberlist: + t = int(i) + result = 0 + for j in range(2, t): + if t % j == 0: + result += 1 + break + if result == 0 and t != 1 and t != 0: + answer += 1 + return answer + + +def solution(numbers): + numberlist = makeNumbers(numbers) + answer = countPrimeNumber(numberlist) + return answer From 1ecd900187404fd28128d067e2766abd2c94f19e Mon Sep 17 00:00:00 2001 From: Minjae Lee <0201.mj.lee@gmail.com> Date: Tue, 18 Jun 2019 14:42:29 +0900 Subject: [PATCH 26/30] =?UTF-8?q?[wangmin]=20=EC=88=98=20=EC=A0=95?= =?UTF-8?q?=EB=A0=AC=ED=95=98=EA=B8=B0=203=20(#74)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 190613/wangmin/bj10989.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 190613/wangmin/bj10989.cpp diff --git a/190613/wangmin/bj10989.cpp b/190613/wangmin/bj10989.cpp new file mode 100644 index 0000000..c555b9a --- /dev/null +++ b/190613/wangmin/bj10989.cpp @@ -0,0 +1,32 @@ +#include +#include + +using namespace std; + +int main(){ + cin.tie(NULL); + cout.tie(NULL); + ios_base :: sync_with_stdio(false); + + int N; + cin >> N; + int a; + vector count(10001, 0); + + + for(int i = 0; i < N; i++){ + cin >> a; + count[a]++; + } + + for(int i = 0; i <= 10001; i++){ + for(int j = count[i]; j > 0; j--){ + cout << i << "\n"; + } + } + + + return 0; +} + + From 0a84b12b94cf167ffca06bf70e47b6a0ab6d45ca Mon Sep 17 00:00:00 2001 From: Hoyoung Jung Date: Tue, 18 Jun 2019 15:06:22 +0900 Subject: [PATCH 27/30] Honux (#75) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fail to solve find prime 프로그래머스 문제 풀다 실패 순열로 구했는데 조합이었다. 내일 하자. * Solve programmers find prime 복잡하다... 여튼 풀긴 풀었네. * Add problem 문제 추가 * [H] 소수찾기 문제풀이 제출합니다. (#73) * H-Index 문제풀이 * H-Index 문제풀이 * 소수 찾기 문제풀이 * [wangmin] 수 정렬하기 3 (#74) * Add 190618 problem --- 190618/problem.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 190618/problem.md diff --git a/190618/problem.md b/190618/problem.md new file mode 100644 index 0000000..886ee22 --- /dev/null +++ b/190618/problem.md @@ -0,0 +1,6 @@ +# programmers 체육복 + +- https://programmers.co.kr/learn/courses/30/lessons/42862 +- 레벨 1 +- 분류: greedy + From 5a7e61649ea1bfcfb437124f22ebc3b8bfd057dc Mon Sep 17 00:00:00 2001 From: Hoyoung Jung Date: Fri, 21 Jun 2019 16:18:07 +0900 Subject: [PATCH 28/30] =?UTF-8?q?Jake=20=EB=AC=B8=EC=A0=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=20(#77)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fail to solve find prime 프로그래머스 문제 풀다 실패 순열로 구했는데 조합이었다. 내일 하자. * Solve programmers find prime 복잡하다... 여튼 풀긴 풀었네. * Add problem 문제 추가 * [H] 소수찾기 문제풀이 제출합니다. (#73) * H-Index 문제풀이 * H-Index 문제풀이 * 소수 찾기 문제풀이 * [wangmin] 수 정렬하기 3 (#74) * Add 190618 problem * Fail to solve 190613 algorithm * Add problems Jake 블로그 관련 문제 추가 --- 190613/honux/input.txt | 11 +++++++++++ 190613/honux/sort.js | 20 ++++++++++++++++++++ 190621/problem.md | 5 +++++ 190624/problem.md | 6 ++++++ 4 files changed, 42 insertions(+) create mode 100644 190613/honux/input.txt create mode 100644 190613/honux/sort.js create mode 100644 190621/problem.md create mode 100644 190624/problem.md diff --git a/190613/honux/input.txt b/190613/honux/input.txt new file mode 100644 index 0000000..5ca0303 --- /dev/null +++ b/190613/honux/input.txt @@ -0,0 +1,11 @@ +10 +5 +2 +3 +1 +4 +2 +3 +5 +1 +7 \ No newline at end of file diff --git a/190613/honux/sort.js b/190613/honux/sort.js new file mode 100644 index 0000000..f9d4c54 --- /dev/null +++ b/190613/honux/sort.js @@ -0,0 +1,20 @@ +var lines = require('fs').readFileSync('/dev/stdin').toString().split('\n'); +var arr = []; +for (var i = 0; i <= 10000; i++) { + arr[i] = 0; +} + +var n = Number(lines[0]); +for (var i = 1; i <= n; i++) { + var x = Number(lines[i]); + arr[x]++; +} + +for (var i = 0; i <= 10000; i++) { + if (arr[i] > 0) { + for (var j = 0; j < arr[i]; j++) { + console.log(i); + } + } +} + diff --git a/190621/problem.md b/190621/problem.md new file mode 100644 index 0000000..ccd5f1b --- /dev/null +++ b/190621/problem.md @@ -0,0 +1,5 @@ +# BOJ 1525 퍼즐 + +- https://www.acmicpc.net/problem/1525 +- 분류: BFS + diff --git a/190624/problem.md b/190624/problem.md new file mode 100644 index 0000000..bbee43d --- /dev/null +++ b/190624/problem.md @@ -0,0 +1,6 @@ +# BOJ 2580 스도쿠 + +- https://www.acmicpc.net/problem/2580 +- 분류: DFS + + From c01004c1b152721142613aae5fb10803e8adbe2c Mon Sep 17 00:00:00 2001 From: Hoyoung Jung Date: Thu, 27 Jun 2019 16:03:09 +0900 Subject: [PATCH 29/30] Try to solve BOJ 2580 Sudoku MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 시간이 많이 걸려서 작성 중 커밋 아직 돌아가지 않는다. --- .gitignore | 3 +++ 190624/2580-sudoku.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++ 190624/input.txt | 9 +++++++ 3 files changed, 66 insertions(+) create mode 100644 190624/2580-sudoku.cpp create mode 100644 190624/input.txt diff --git a/.gitignore b/.gitignore index ad46b30..500f3f6 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,6 @@ typings/ # next.js build output .next + +# for cpp +a.out diff --git a/190624/2580-sudoku.cpp b/190624/2580-sudoku.cpp new file mode 100644 index 0000000..3e575f0 --- /dev/null +++ b/190624/2580-sudoku.cpp @@ -0,0 +1,54 @@ +#include +#include + +int b[9][9]; + +using namespace std; + +vector findNums(int i,int j) { + //map nums; + //checkv(i, nums); + //checkh(j, nums); + //checkbox(i,j, nums); +} + +bool find = false; + +void fillNums(int i, int j) { + if (find) return; + if (i == 9 && j == 9 && b[i][j] != 0) { + find = true; + return; + } + + int jn = j < 9 ? j + 1: j; + int in = jn == j && i < 9; i + 1: i; + + if (b[i][j] == 0) { + vector nums = findNums(i,j); + if (nums.size() == 0) return; + for (auto n: nums) { + board[i][j] = n; + fillNums(in, jn); + } + } + return; +} + +int main() { + char c; + for (int i = 0; i < 9; i++) { + for (int j = 0; j < 9; j++) { + cin >> c; + b[i][j] = c - '0'; + } + } + fillNums(0,0); + for (int i = 0; i < 9; i++) { + for (int j = 0; j < 9; j++) { + cout << b[i][j] << " "; + } + cout << "\n"; + } + return 0; +} diff --git a/190624/input.txt b/190624/input.txt new file mode 100644 index 0000000..2ea6910 --- /dev/null +++ b/190624/input.txt @@ -0,0 +1,9 @@ +0 3 5 4 6 9 2 7 8 +7 8 2 1 0 5 6 0 9 +0 6 0 2 7 8 1 3 5 +3 2 1 0 4 6 8 9 7 +8 0 4 9 1 3 5 0 6 +5 9 6 8 2 0 4 1 3 +9 1 7 6 5 2 0 8 0 +6 0 3 7 0 1 9 5 2 +2 5 8 3 9 4 7 6 0 From 764e953bf633924b3763b84b79ce37c7749d4c24 Mon Sep 17 00:00:00 2001 From: Hoyoung Jung Date: Tue, 4 Feb 2020 18:08:21 +0900 Subject: [PATCH 30/30] =?UTF-8?q?20024=20=EC=95=8C=EA=B3=A0=EB=A6=AC?= =?UTF-8?q?=EC=A6=98=20-=20=ED=94=84=EB=A1=9C=EA=B7=B8=EB=9E=98=EB=A8=B8?= =?UTF-8?q?=EC=8A=A4=20=EB=AC=B8=EC=9E=90=EC=97=B4=20=EC=95=95=EC=B6=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 분류: 완전탐색 - 난이도: 2 - 풀만한데 시간이 좀 걸림 - 더 좋은 방법을 찾아 보자 --- 200204/60057-Solution.java | 56 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 200204/60057-Solution.java diff --git a/200204/60057-Solution.java b/200204/60057-Solution.java new file mode 100644 index 0000000..aec7a94 --- /dev/null +++ b/200204/60057-Solution.java @@ -0,0 +1,56 @@ +//programmers 60057 카카오 공채 문자열 압축 +//어렵진 않은데 시간이 오래 걸렸다. + +import java.util.List; +import java.util.ArrayList; + +class Solution { + + private List cutString(String origin, int size) { + List ret = new ArrayList<>(); + for (int i = 0; i < origin.length(); i += size) { + int e = (i + size) > origin.length() ? origin.length(): i + size; + String str = origin.substring(i, e); + ret.add(str); + } + return ret; + } + + private String findCompressString(String str, int size) { + List slist = cutString(str, size); + + int count = 0; + StringBuffer newStr = new StringBuffer(); + + String prev = slist.get(0); + newStr.append(prev); + int repeat = 1; + for (int i = 1; i < slist.size(); i++) { + String curr = slist.get(i); + if(curr.equals(prev)) { + repeat++; + } else { + if (repeat != 1) { + newStr.append(Integer.toString(repeat)); + repeat = 1; + } + newStr.append(curr); + prev = curr; + } + } + + if (repeat != 1) { + newStr.append(Integer.toString(repeat)); + } + return newStr.toString(); + } + + public int solution(String s) { + int ans = s.length(); + for(int i = 1; i < s.length(); i++) { + ans = Math.min(ans, findCompressString(s, i).length()); + } + return ans; + } +} +