From 57047c7b4ba97c31b57dda00a7075c887ae84430 Mon Sep 17 00:00:00 2001 From: UICHANLEE <87562428+UICHANLEE@users.noreply.github.com> Date: Mon, 26 Dec 2022 13:47:14 +0900 Subject: [PATCH 1/2] 22.12.26 --- ...4\354\232\264 \352\270\200\354\236\220.py" | 25 ++++++++++++++++++ "\354\202\274\354\264\235\354\202\254.py" | 26 +++++++++++++++++++ "\354\275\234\353\235\274.py" | 12 +++++++++ ...34\355\214\214\354\235\264\355\204\260.py" | 19 ++++++++++++++ 4 files changed, 82 insertions(+) create mode 100644 "\352\260\200\354\236\245 \352\260\200\352\271\214\354\232\264 \352\270\200\354\236\220.py" create mode 100644 "\354\202\274\354\264\235\354\202\254.py" create mode 100644 "\354\275\234\353\235\274.py" create mode 100644 "\355\221\270\353\223\234\355\214\214\354\235\264\355\204\260.py" diff --git "a/\352\260\200\354\236\245 \352\260\200\352\271\214\354\232\264 \352\270\200\354\236\220.py" "b/\352\260\200\354\236\245 \352\260\200\352\271\214\354\232\264 \352\270\200\354\236\220.py" new file mode 100644 index 0000000..fbee30f --- /dev/null +++ "b/\352\260\200\354\236\245 \352\260\200\352\271\214\354\232\264 \352\270\200\354\236\220.py" @@ -0,0 +1,25 @@ +from collections import defaultdict +from copy import deepcopy + +def solution(s): + answer = [] + split = [] + exist = [] + for i in range(len(s)): + split.append(s[i]) + + spell = defaultdict(int) + answer = deepcopy(split) + + for i in range(len(split)): + if split[i] not in exist: + exist.append(split[i]) + answer[i] = -1 + spell[split[i]] = split.index(split[i]) + elif split[i] in exist: + temp = answer.index(split[i]) + spell[split[i]] = answer.index(split[i]) - spell[split[i]] + answer[i] = spell[split[i]] + spell[split[i]] = temp + + return answer \ No newline at end of file diff --git "a/\354\202\274\354\264\235\354\202\254.py" "b/\354\202\274\354\264\235\354\202\254.py" new file mode 100644 index 0000000..1e432e7 --- /dev/null +++ "b/\354\202\274\354\264\235\354\202\254.py" @@ -0,0 +1,26 @@ +''' +한국중학교에 다니는 학생들은 각자 정수 번호를 갖고 있습니다. 이 학교 학생 3명의 정수 번호를 더했을 때 0이 되면 3명의 학생은 삼총사라고 합니다. +예를 들어, 5명의 학생이 있고, 각각의 정수 번호가 순서대로 -2, 3, 0, 2, -5일 때, 첫 번째, 세 번째, 네 번째 학생의 정수 번호를 더하면 0이므로 세 학생은 삼총사입니다. + 또한, 두 번째, 네 번째, 다섯 번째 학생의 정수 번호를 더해도 0이므로 세 학생도 삼총사입니다. 따라서 이 경우 한국중학교에서는 두 가지 방법으로 삼총사를 만들 수 있습니다. + +한국중학교 학생들의 번호를 나타내는 정수 배열 number가 매개변수로 주어질 때, 학생들 중 삼총사를 만들 수 있는 방법의 수를 return 하도록 solution 함수를 완성하세요. +''' +def solution(number): + answer = 0 + number.sort() + for i in range(len(number)): + temp = number[i] + ii = number.index(temp) + for j in range(ii+1, len(number)): + temp2 = number[j] + ij = number.index(temp2) + for k in range(ij+1, len(number)): + temp3 = number[k] + if temp + temp2 + temp3 == 0: + answer += 1 + + + + return answer + +print(solution([-2, 3, 0, 2, -5])) \ No newline at end of file diff --git "a/\354\275\234\353\235\274.py" "b/\354\275\234\353\235\274.py" new file mode 100644 index 0000000..ae08f15 --- /dev/null +++ "b/\354\275\234\353\235\274.py" @@ -0,0 +1,12 @@ +def solution(a, b, n): + answer = 0 + while n >= a: + recycle = n // a + answer += recycle * b + n = n - a * recycle + recycle * b + + + return answer + +print(solution(2, 1, 20)) +print(solution(3, 1, 20)) \ No newline at end of file diff --git "a/\355\221\270\353\223\234\355\214\214\354\235\264\355\204\260.py" "b/\355\221\270\353\223\234\355\214\214\354\235\264\355\204\260.py" new file mode 100644 index 0000000..272773f --- /dev/null +++ "b/\355\221\270\353\223\234\355\214\214\354\235\264\355\204\260.py" @@ -0,0 +1,19 @@ +def solution(food): + answer = '' + for i in range(1, len(food)): + if food[i] >= 2: + while food[i] >= 2: + ch = food.index(food[i]) + ch = str(ch) + answer += ch + food[i] -= 2 + answer += '0' + a = answer[:-1] + a = list(a) + a.reverse() + a = "".join(a) + answer += a + + return answer + +solution([1, 3, 4, 6]) \ No newline at end of file From 3f99639033d0ec9ff0401b9b14f0ebec40e735da Mon Sep 17 00:00:00 2001 From: UICHANLEE <87562428+UICHANLEE@users.noreply.github.com> Date: Thu, 9 Feb 2023 22:26:43 +0900 Subject: [PATCH 2/2] LV1 --- ...40\355\232\250\352\270\260\352\260\204.py" | 23 ++++++++++ ...0\354\235\230 \353\254\264\352\270\260.py" | 24 ++++++++++ ... \354\210\230 \354\260\276\352\270\260.py" | 10 ++++ ...4\354\235\230 \354\225\224\355\230\270.py" | 36 +++++++++++++++ ...0\354\235\230 \354\240\204\353\213\271.py" | 19 ++++++++ ...4 \353\202\230\353\210\204\352\270\260.py" | 21 +++++++++ ...40\355\230\225\352\262\200\354\202\254.py" | 28 +++++++++++ ...53\354\236\220\354\247\235\352\266\201.py" | 19 ++++++++ ...0\352\263\274_\353\260\233\352\270\260.py" | 46 +++++++++++++++++++ ...00\353\254\270\354\236\220\354\227\264.py" | 11 +++++ 10 files changed, 237 insertions(+) create mode 100644 "LV1/\352\260\234\354\235\270\354\240\225\353\263\264 \354\210\230\354\247\221 \354\234\240\355\232\250\352\270\260\352\260\204.py" create mode 100644 "LV1/\352\270\260\354\202\254\353\213\250\354\233\220\354\235\230 \353\254\264\352\270\260.py" create mode 100644 "LV1/\353\202\230\353\250\270\354\247\200\352\260\200 1\354\235\264 \353\220\230\353\212\224 \354\210\230 \354\260\276\352\270\260.py" create mode 100644 "LV1/\353\221\230\353\247\214\354\235\230 \354\225\224\355\230\270.py" create mode 100644 "LV1/\353\252\205\354\230\210\354\235\230 \354\240\204\353\213\271.py" create mode 100644 "LV1/\353\254\270\354\236\220\354\227\264 \353\202\230\353\210\204\352\270\260.py" create mode 100644 "LV1/\354\204\261\352\262\251\354\234\240\355\230\225\352\262\200\354\202\254.py" create mode 100644 "LV1/\354\210\253\354\236\220\354\247\235\352\266\201.py" create mode 100644 "LV1/\354\213\240\352\263\240_\352\262\260\352\263\274_\353\260\233\352\270\260.py" create mode 100644 "LV1/\355\201\254\352\270\260\352\260\200\354\236\221\354\235\200\353\254\270\354\236\220\354\227\264.py" diff --git "a/LV1/\352\260\234\354\235\270\354\240\225\353\263\264 \354\210\230\354\247\221 \354\234\240\355\232\250\352\270\260\352\260\204.py" "b/LV1/\352\260\234\354\235\270\354\240\225\353\263\264 \354\210\230\354\247\221 \354\234\240\355\232\250\352\270\260\352\260\204.py" new file mode 100644 index 0000000..399dae2 --- /dev/null +++ "b/LV1/\352\260\234\354\235\270\354\240\225\353\263\264 \354\210\230\354\247\221 \354\234\240\355\232\250\352\270\260\352\260\204.py" @@ -0,0 +1,23 @@ +def solution(today, terms, privacies): + answer = [] + dic = {} + ver = [] + for i in range(len(terms)): + terms[i] = terms[i].split(' ') + dic[terms[i][0]] = terms[i][1] + for j in range(len(privacies)): + privacies[j] = privacies[j].split(' ') + if privacies[j][1] in dic.keys(): + ver.append([privacies[j][1],((int(today[:4]) - int(privacies[j][0][:4])) * 12 + \ + (int(today[5:7]) - int(privacies[j][0][5:7])))*28 + (int(today[8:10]) - int(privacies[j][0][8:10]))]) + + for i in range(0, len(ver)): + if (ver[i][1]) >= int(dic[ver[i][0]])*28: + answer.append(i+1) + + + return answer + + + +print(solution("2022.05.19", ["A 6", "B 12", "C 3"] , ["2021.05.02 A", "2021.07.01 B", "2022.02.19 C", "2022.02.20 C"])) \ No newline at end of file diff --git "a/LV1/\352\270\260\354\202\254\353\213\250\354\233\220\354\235\230 \353\254\264\352\270\260.py" "b/LV1/\352\270\260\354\202\254\353\213\250\354\233\220\354\235\230 \353\254\264\352\270\260.py" new file mode 100644 index 0000000..ada1322 --- /dev/null +++ "b/LV1/\352\270\260\354\202\254\353\213\250\354\233\220\354\235\230 \353\254\264\352\270\260.py" @@ -0,0 +1,24 @@ +def solution(number, limit, power): + answer = 0 + yaksu = [i for i in range(1, number+1)] + count = [] + + for i in range(number): + if yaksu[i] >= 2: + for j in range(1, yaksu[i]+1): + if yaksu[i] % j ==0: + count.append(j) + + else: + count.append(yaksu[i]) + yaksu[i] = len(count) + count.clear() + + for i in range(len(yaksu)): + if yaksu[i] > limit: + yaksu[i] = power + + answer += yaksu[i] + return answer + +print(solution(5, 3, 2)) \ No newline at end of file diff --git "a/LV1/\353\202\230\353\250\270\354\247\200\352\260\200 1\354\235\264 \353\220\230\353\212\224 \354\210\230 \354\260\276\352\270\260.py" "b/LV1/\353\202\230\353\250\270\354\247\200\352\260\200 1\354\235\264 \353\220\230\353\212\224 \354\210\230 \354\260\276\352\270\260.py" new file mode 100644 index 0000000..21af078 --- /dev/null +++ "b/LV1/\353\202\230\353\250\270\354\247\200\352\260\200 1\354\235\264 \353\220\230\353\212\224 \354\210\230 \354\260\276\352\270\260.py" @@ -0,0 +1,10 @@ +def solution(n): + answer = 0 + ele = [] + for i in range(1, n): + if n % i == 1: + ele.append(i) + answer = ele.pop(0) + return answer + +print(solution(10)) \ No newline at end of file diff --git "a/LV1/\353\221\230\353\247\214\354\235\230 \354\225\224\355\230\270.py" "b/LV1/\353\221\230\353\247\214\354\235\230 \354\225\224\355\230\270.py" new file mode 100644 index 0000000..9bad780 --- /dev/null +++ "b/LV1/\353\221\230\353\247\214\354\235\230 \354\225\224\355\230\270.py" @@ -0,0 +1,36 @@ +def solution(s, skip, index): + answer = '' + + ran = [] + for j in range(97, 123): + if chr(j) not in skip: + ran.append(j) + + for i in range(len(s)): + if (ran.index(ord(s[i])) + index) < len(ran): + asci = ran[((ran.index(ord(s[i])) + index))] + else: + asci = ran[((ran.index(ord(s[i]))) + index) - len(ran)] + + answer += chr(asci) + + return answer + +# def solution(s, skip, index): +# answer = '' + +# ran = [i for i in range(97, 123)] +# for j in range(len(skip)): +# vs = ord(skip[j]) +# if vs in ran: +# ran.remove(vs) + +# for i in range(len(s)): +# if (ran.index(ord(s[i])) + index) < len(ran): +# asci = ran[((ran.index(ord(s[i])) + index))] +# else: +# asci = ran[((ran.index(ord(s[i]))) + index) - len(ran)] + +# answer += chr(asci) + +# return answer diff --git "a/LV1/\353\252\205\354\230\210\354\235\230 \354\240\204\353\213\271.py" "b/LV1/\353\252\205\354\230\210\354\235\230 \354\240\204\353\213\271.py" new file mode 100644 index 0000000..4bcf6cf --- /dev/null +++ "b/LV1/\353\252\205\354\230\210\354\235\230 \354\240\204\353\213\271.py" @@ -0,0 +1,19 @@ +def solution(k, score): + answer = [] + lst = [] + for i in range(len(score)): + if len(lst) < k: + lst.append(score[i]) + lst.sort() + answer.append(lst[0]) + else: + if lst[0] < score[i]: + lst[0] = score[i] + lst.sort() + answer.append(lst[0]) + else: + lst = lst + answer.append(lst[0]) + + + return answer diff --git "a/LV1/\353\254\270\354\236\220\354\227\264 \353\202\230\353\210\204\352\270\260.py" "b/LV1/\353\254\270\354\236\220\354\227\264 \353\202\230\353\210\204\352\270\260.py" new file mode 100644 index 0000000..61a71b0 --- /dev/null +++ "b/LV1/\353\254\270\354\236\220\354\227\264 \353\202\230\353\210\204\352\270\260.py" @@ -0,0 +1,21 @@ +def solution(s): + answer = 0 + + S = [] + US = [] + result = [] + for i in range(len(s)): + if len(S) == 0: + S.append(s[i]) + elif s[i] == S[0]: + S.append(s[i]) + elif s[i] != S[0]: + US.append(s[i]) + if len(S) == len(US): + result.append(S.extend(US)) + S.clear() + US.clear() + if len(S) != 0: + result.append(S) + answer += len(result) + return answer diff --git "a/LV1/\354\204\261\352\262\251\354\234\240\355\230\225\352\262\200\354\202\254.py" "b/LV1/\354\204\261\352\262\251\354\234\240\355\230\225\352\262\200\354\202\254.py" new file mode 100644 index 0000000..62b585b --- /dev/null +++ "b/LV1/\354\204\261\352\262\251\354\234\240\355\230\225\352\262\200\354\202\254.py" @@ -0,0 +1,28 @@ +from collections import defaultdict +def solution(survey, choices): + answer = '' + dic = defaultdict(int) + type = ['RT', 'CF', 'JM', 'AN'] + + for i in range(len(choices)): + if choices[i] == 4: + dic[survey[i][0]] += 0 + dic[survey[i][1]] += 0 + elif choices[i] <= 3: + dic[survey[i][0]] += (4-choices[i]) + dic[survey[i][1]] += 0 + elif choices[i] <= 7: + dic[survey[i][1]] += (choices[i]-4) + dic[survey[i][0]] += 0 + + for i in range(len(type)): + type[i] = ''.join(sorted(type[i])) + print(type[i]) + if dic[type[i][0]] >= dic[type[i][1]]: + answer += type[i][0] + else: + answer += type[i][1] + + + return answer +print(solution(["AN", "CF", "MJ", "RT", "NA"], [5, 3, 2, 7, 5])) \ No newline at end of file diff --git "a/LV1/\354\210\253\354\236\220\354\247\235\352\266\201.py" "b/LV1/\354\210\253\354\236\220\354\247\235\352\266\201.py" new file mode 100644 index 0000000..a423ce6 --- /dev/null +++ "b/LV1/\354\210\253\354\236\220\354\247\235\352\266\201.py" @@ -0,0 +1,19 @@ +def solution(X, Y): + answer = '' + temp = [] + X_i = [] + for i in range(len(X)): + X_i.append(X[i]) + for j in range(len(X_i)): + if X_i[j] in Y: + temp.append(X_i[j]) + Y = Y.replace(X_i[j], '', 1) + temp.sort(reverse = True) + answer = ''.join(temp) + if answer == '': + answer = '-1' + if answer.strip('0') == '': + answer = '0' + return answer + +print(solution("100", "203045")) \ No newline at end of file diff --git "a/LV1/\354\213\240\352\263\240_\352\262\260\352\263\274_\353\260\233\352\270\260.py" "b/LV1/\354\213\240\352\263\240_\352\262\260\352\263\274_\353\260\233\352\270\260.py" new file mode 100644 index 0000000..fa00ea9 --- /dev/null +++ "b/LV1/\354\213\240\352\263\240_\352\262\260\352\263\274_\353\260\233\352\270\260.py" @@ -0,0 +1,46 @@ +from collections import defaultdict +import collections +def solution(유저_아이디 = list, 설명 = list, 정지_기준 = int) -> list: + answer = [] + + answer = 유저_아이디 + 누가_누구에게 = defaultdict(list) + 유저별_신고당한_횟수 = defaultdict(int) + 신고_유저_회신_횟수 = defaultdict(int) + + 신고당한_아이디 = [] + 정지된_아이디 = [] + + for 요소 in 유저_아이디: + 누가_누구에게[요소] = [] + + 설명 = list(set(설명)) + for 인덱스 in range(len(설명)): + 설명[인덱스] = 설명[인덱스].split(' ') + 누가_누구에게[설명[인덱스][0]].append(설명[인덱스][1]) + 신고당한_아이디.append(설명[인덱스][1]) + + 유저별_신고당한_횟수 = collections.Counter(신고당한_아이디) + for 아이디 in 유저_아이디: + if 아이디 not in 신고당한_아이디: + 유저별_신고당한_횟수[아이디] += 0 + + 신고당한_아이디 = list(set(신고당한_아이디)) + + for 요소_ in 신고당한_아이디: + if 유저별_신고당한_횟수[요소_] >= 정지_기준: + 정지된_아이디.append(요소_) + + for 아이디 in 유저_아이디: + for 요소__ in range(len(누가_누구에게[아이디])): + if 누가_누구에게[아이디][요소__] in 정지된_아이디: + 신고_유저_회신_횟수[아이디] += 1 + else: + 신고_유저_회신_횟수[아이디] += 0 + + for 인덱스__ in range(len(answer)): + answer[인덱스__] = 신고_유저_회신_횟수[answer[인덱스__]] + + return answer + +print(solution(['muzi', 'frodo', 'apeach', 'neo'], ["muzi frodo","apeach frodo","frodo neo","muzi neo","apeach muzi"], 2)) \ No newline at end of file diff --git "a/LV1/\355\201\254\352\270\260\352\260\200\354\236\221\354\235\200\353\254\270\354\236\220\354\227\264.py" "b/LV1/\355\201\254\352\270\260\352\260\200\354\236\221\354\235\200\353\254\270\354\236\220\354\227\264.py" new file mode 100644 index 0000000..e8af947 --- /dev/null +++ "b/LV1/\355\201\254\352\270\260\352\260\200\354\236\221\354\235\200\353\254\270\354\236\220\354\227\264.py" @@ -0,0 +1,11 @@ +def solution(t, p): + answer = 0 + cut = len(p) + Operations = [] + for i in range(len(t)-cut+1): + Operations.append(t[i:i+cut]) + + for i in range(len(Operations)): + if int(p) >= int(Operations[i]): + answer += 1 + return answer \ No newline at end of file