Skip to content
Merged
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
6 changes: 0 additions & 6 deletions 190521/k_number.js

This file was deleted.

28 changes: 28 additions & 0 deletions 190523/wangmin/pg42746.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

bool func(string a, string b){
return a+b > b+a ? true : false;
}

string solution(vector<int> numbers) {
string answer = "";
vector<string> 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;
}
34 changes: 34 additions & 0 deletions 190524/circus/hIndex.js
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
6 changes: 6 additions & 0 deletions 190524/honux/h-index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function solution(citations) {
citations.sort((a,b) => (b - a));
let i = 0;
while (i + 1 <= citations[i]) i++;
return i;
}
13 changes: 13 additions & 0 deletions 190524/ruby/solution.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const solution = (c) => {
c.sort((a,b)=>b-a);
for(let i=0; i<c.length; i++){
if(i+1 > c[i]){
return i
}else if(i+1 === c[i]){
return c[i]
}
}
return c.length
}

console.log(solution([1,1,3,4,8]))
21 changes: 21 additions & 0 deletions 190524/wangmin/pg42747.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

int solution(vector<int> 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;
}

17 changes: 17 additions & 0 deletions 190527/H/exam.py
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions 190527/circus/exam.js
Original file line number Diff line number Diff line change
@@ -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;
}
43 changes: 43 additions & 0 deletions 190527/hyodol/mock_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include <iostream>
#include <vector>
using namespace std;

vector<int> solution(vector<int> answers) {
vector<vector<int> > 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<int> 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<int> 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<int> result1 = solution({1, 2, 3, 4, 5});
for (int num : result1) cout << num << " ";
cout << '\n';

vector<int> result2 = solution({1, 3, 2, 4, 2});
for (int num : result2) cout << num << " ";
cout << '\n';

return 0;
}
24 changes: 24 additions & 0 deletions 190527/ingleby/mouigosa.py
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions 190527/mockExam.js
Original file line number Diff line number Diff line change
@@ -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
}
46 changes: 46 additions & 0 deletions 190527/mukeunzi/MockTest.java
Original file line number Diff line number Diff line change
@@ -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<Integer> answer = new ArrayList<>();

for(int i=0; i<answers.length; i++){
if(way1[i%way1.length] == answers[i]){
cnt[0]++;
}
if(way2[i%way2.length] == answers[i]){
cnt[1]++;
}
if(way3[i%way3.length] == answers[i]){
cnt[2]++;
}
}

max = cnt[0];
if(max < cnt[1]){
max = cnt[1];
}
if(max < cnt[2]){
max = cnt[2];
}

for(int i=0; i<cnt.length; i++){
if(max == cnt[i]){
answer.add(i+1);
}
}

result = new int[answer.size()];
for(int i=0; i<answer.size(); i++){
result[i] = answer.get(i);
}

return result;
}
}
31 changes: 31 additions & 0 deletions 190527/nailer/supoja.py
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions 190527/ruby/solution.js
Original file line number Diff line number Diff line change
@@ -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
}
Loading