Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
seongwon02 committed May 20, 2024
2 parents b8d62fc + a1dddf8 commit 8986c52
Show file tree
Hide file tree
Showing 31 changed files with 615 additions and 32 deletions.
6 changes: 6 additions & 0 deletions ESKO/1to10/1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def solution(list):
list.sort()
return list # 그냥 list.sort() 반환하면 안되나?

arr = [1, -5, 2, 4, 3]
print(solution(arr))
7 changes: 7 additions & 0 deletions ESKO/1to10/2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
def solution(arr):
newArr = list(set(arr))
newArr.sort(reverse=True) # 내림차순 정렬
return newArr

nums = [4, 2, 2, 1, 3, 4]
print(solution(nums))
10 changes: 10 additions & 0 deletions ESKO/1to10/3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
def solution(numbers):
answer = []
for i in range(len(numbers)):
for j in range(i+1, len(numbers)):
sum = numbers[i] + numbers[j]
answer.append(sum)

res = list(set(answer))
res.sort()
return res
26 changes: 26 additions & 0 deletions HJBAE/1to10/4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import random

answer = [random.randint(1, 5) for _ in range(100)]
# answer.append(random.randint(1, 5)) 으로 하려고 했는데 list comprehension 하면 더 간결하게 된대서 써봄

patterns = [[1, 2, 3, 4, 5], [2, 1, 2, 3, 2, 4, 2, 5], [3, 3, 1, 1, 2, 2, 4, 4, 5, 5]]

# 찍는 패턴 만듦.. 간결하게 될 것 같은데..

def solution(pattern):
score = [[0] for _ in range(3)]

for i in range(len(pattern)): #len(pattern) == 3
for j in range(100):
if (pattern[i][j % len([pattern])] == answer[j]):
score[i][0] += 1

max_score = max(score)
max_score_index = score.index(max_score)


return max_score_index, max_score[0]

mvp_index, max_score = solution(patterns)

print(f"winner is player {mvp_index + 1} & score is {max_score}")
15 changes: 15 additions & 0 deletions HJBAE/1to10/5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import numpy as np

arr1 = np.array([[1, 4], [3, 2], [4, 1]])
arr2 = np.array([[3, 3], [3, 3]])
# 추가로 제시된 행렬은.. arr3, arr4로 해서 돌려봄

arr3 = np.array([[2, 3, 2], [4, 2, 4], [3, 1, 4]])
arr4 = np.array([[5, 4, 3], [2, 4, 1], [3, 1, 1]])

def sol(arr1, arr2):
res = np.dot(arr1, arr2)
return res

print(sol(arr1, arr2))
print(sol(arr3, arr4))
23 changes: 23 additions & 0 deletions HJBAE/1to10/5_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
arr1 = ([[1, 4], [3, 2], [4, 1]])
arr2 = ([[3, 3], [3, 3]])

arr3 = ([[2, 3, 2], [4, 2, 4], [3, 1, 4]])
arr4 = ([[5, 4, 3], [2, 4, 1], [3, 1, 1]])


#len(arr1) = 3
#len(arr1[1]) = 2


def solution(arr_1, arr_2):
res = [[0] * len(arr_2) for _ in range(len(arr_1))]
for i in range(len(arr_1)):
for j in range(len(arr_1)):
for k in range(len(arr_2)):
res[i][j] += arr_1[i][k] * arr_2[k][j]
return res

print(solution(arr1, arr2))
print(solution(arr3, arr4))

# (3X2) X (2X2) 행렬 = (3X2)
25 changes: 25 additions & 0 deletions HJBAE/1to10/5_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
arr1 = ([[1, 4], [3, 2], [4, 1]])
arr2 = ([[3, 3], [3, 3]])

arr3 = ([[2, 3, 2], [4, 2, 4], [3, 1, 4]])
arr4 = ([[5, 4, 3], [2, 4, 1], [3, 1, 1]])

def solution(arr_1, arr_2):
row1, column1 = len(arr_1), len(arr_1[0])
row2, column2 = len(arr_2), len(arr_2[0])

res = [[0] * len(arr_1)] * len(arr_2[0])

for i in range(len(arr_1)): # len(arr_1) == len(row1)
for j in range(len(arr_2[0])): # len(arr_1) == len(column1)
for k in range(len(arr_1[0])): # len(arr_2) == len(column2)
res[i][j] += arr_1[i][k] * arr_2[k][j]

return res


print(solution(arr1, arr2))
print(solution(arr3, arr4))



File renamed without changes.
Empty file added HJBAE/91to100/temp.py
Empty file.
3 changes: 3 additions & 0 deletions JEOH/1to10/1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def solution(arr1):
arr1.sort()
return arr1
4 changes: 4 additions & 0 deletions JEOH/1to10/2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
def solution(arr2):
arr3=list(set(arr2))
arr3.sort(reverse=True)
return arr3
8 changes: 8 additions & 0 deletions JEOH/1to10/3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def solution(numbers):
answer = []
for i in range(len(numbers)):
for j in range(len(numbers)):
if i!=j:
answer.append(numbers[i]+numbers[j])
answer=sorted(set(answer))
return answer
18 changes: 18 additions & 0 deletions JEOH/1to10/4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
def solution(answers):
answer = []
name=[1,2,3]
score=[0,0,0]
result1=[1,2,3,4,5]
result2=[2,1,2,3,2,4,2,5]
result3=[3,3,1,1,2,2,4,4,5,5]
for i in range(len(answers)):
if answers[i]==result1[i%len(result1)]:
score[0]+=1
if answers[i]==result2[i%len(result2)]:
score[1]+=1
if answers[i]==result3[i%len(result3)]:
score[2]+=1
for k in range(len(score)):
if score[k]==max(score):
answer.append(k+1)
return answer
5 changes: 5 additions & 0 deletions JYPARK/1to10/01.py.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#문제01

def solution(arr):
arr.sort()
return arr
5 changes: 5 additions & 0 deletions JYPARK/1to10/02.py.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#문제02
def solution(arr):
result = list(set(arr)) #중복제거, 오름차순정리
result = result.sort(reverse = True)
return result
Empty file added JYPARK/1to10/03.c.c
Empty file.
11 changes: 11 additions & 0 deletions JYPARK/1to10/03.py.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#문제03
def solution(numbers):
result = []

for i in range(len(numbers)):
for j in range(i+1, len(numbers)):
result.append(numbers[i] + numbers[j])

result = sorted(set(result))
return result

90 changes: 90 additions & 0 deletions JYPARK/1to10/04.c.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#include <stdio.h>

int solution(int answer[]){
int count = 0;
int index = 0;
int score[] = {0};
int result[] = {0};
int player1[] = {1, 2, 3, 4, 5}; //5
int player2[] = {2, 1, 2, 3, 2, 4, 2, 5}; //8
int player3[] = {3, 3, 1, 1, 2, 2, 4, 4, 5, 5}; //10

//player1의 정답 개수
for(int i = 0; i < sizeof(answer); i++){
if(answer[i] == player1[index]){
count++;
}
index++;
if(index == 5){
index = 0;
}

}
score[0] = count;

//player2의 정답 개수
for(int i = 0; i < sizeof(answer); i++){
if(answer[i] == player2[index]){
count++;
}
index++;
if(index == 8){
index = 0;
}

}
score[1] = count;

//player3의 정답 개수
for(int i = 0; i < sizeof(answer); i++){
if(answer[i] == player3[index]){
count++;
}
index++;
if(index == 10){
index = 0;
}

}
score[2] = count;

//점수 최댓값 구하기
int hihest_score = 0;
for(int i = 1; i<3; i++){
hihest_score = score[0];
if(score[i] > hihest_score){
hihest_score = score[i];
}
}

//점수 최댓값 가지는 player구하기
index = 0;
for(int i = 0; i<3;i++){
if(score[i] == hihest_score){
result[index] = i+1;
}
}
return result;
}


int main(){
int answers[] = {1, 2, 3, 4, 5};
int result = solution(answers);
return 0;
}



/*int solution2(int answer[]){
int player1[] = {1, 2, 3, 4, 5}; //5
int player2[] = {2, 1, 2, 3, 2, 4, 2, 5}; //8
int player3[] = {3, 3, 1, 1, 2, 2, 4, 4, 5, 5}; //10
int count = 0;
for(int i = 0; i< sizeof(answer); i++){
if(player1[i % sizeof(player1)] == answer[i]){
count++;
}
}
}*/
26 changes: 26 additions & 0 deletions JYPARK/1to10/04.py.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#문제04
def soolution(answers):

patterns = [
[1, 2, 3, 4, 5],
[2, 1, 2, 3, 2, 4, 2, 5],
[3, 3, 1, 1, 2, 2, 4, 4, 5, 5]
]

#수포자들의 점수를 저장할 리스트
scores = [0] * 3

for i, answer in enumerate(answers):
for j, pattern in enumerate(patterns):
if answer == pattern[i % len(pattern)]:
scores[j] += 1

max_score = max(scores)

higest_scores = []
for i, score in enumerate(scores):
if score == max_score:
higest_scores.append(i+1)

return higest_scores

27 changes: 27 additions & 0 deletions JYPARK/1to10/05.c.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//문제05
#include <stdio.h>

int solution(int arr1[][100], int arr2[][100]){
int sum;
int result[100][100];
int row = sizeof(arr1) / sizeof(arr1[0]);
int col = sizeof(arr2[0]) / sizeof(int);
int arr2_row = sizeof(arr2)/sizeof(arr2[0]);


for(int i = 0; i < row; i++){
for(int j = 0; j < col; j++){
for(int k = 0; k < arr2_row; k++){
result[i][j] = arr1[i][k] * arr2[k][j];

}
}
}
return result;
}

/*int main(){
int test[3][2];
printf("%d", sizeof(test));
return 0;
} */
Loading

0 comments on commit 8986c52

Please sign in to comment.