-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
๐merge: [230816] PGS ์คํจ์จ, ํ๋ณดํค - 2๋ฌธ์ (#98)
* โจfeat: 8์16์ผ ํ๋ก๊ทธ๋๋จธ์ค ๋ฌธ์ ํ์ด * โจfeat: 8์25์ผ PGS ๋ฌธ์ ํ์ด ์ค๋์ ํ๋ง ๋๋์ผ๋ก ํ์ดํ์ต๋๋ค!
- Loading branch information
1 parent
5a84784
commit b72ba4a
Showing
4 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
JeonHyoChang/Season2/23.08.16 ์นด์นด์ค 2๋ฌธ์ /์คํจ์จ.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
def solution(N, stages): | ||
dic = {} | ||
for i in range(1, N + 1): | ||
dic[i] = stages.count(i) | ||
|
||
users = len(stages) | ||
answerTemp = [] | ||
for i in range(1, N + 1): | ||
if users != 0: | ||
answerTemp.append((dic[i] / users, i)) | ||
else: | ||
answerTemp.append((0, i)) | ||
users -= dic[i] | ||
print(answerTemp) | ||
|
||
answerTemp02 = sorted(answerTemp, key=lambda x: (-x[0], x[1])) | ||
answer = [x[1] for x in answerTemp02] | ||
return answer | ||
|
||
|
||
print(solution(5, [2, 1, 2, 6, 2, 4, 3, 3])) | ||
print(solution(4, [4, 4, 4, 4, 4])) | ||
print(solution(2, [1, 1, 1, 1])) |
34 changes: 34 additions & 0 deletions
34
JeonHyoChang/Season2/23.08.16 ์นด์นด์ค 2๋ฌธ์ /ํ๋ณดํค.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from itertools import combinations | ||
|
||
|
||
def solution(relation): | ||
row = len(relation) | ||
col = len(relation[0]) | ||
relationCombinations = [] | ||
|
||
for i in range(1, col + 1): | ||
relationCombinations.extend(combinations(range(col), i)) | ||
|
||
# ์ ์ผ์ฑ ์ฒดํฌ | ||
uniqueKeys = [] | ||
for x in relationCombinations: | ||
tempSet = set() | ||
for i in range(row): | ||
tempSet.add(tuple(relation[i][j] for j in x)) | ||
if len(tempSet) == row: | ||
uniqueKeys.append(x) | ||
print(uniqueKeys) | ||
|
||
# ์ต์์ฑ ์ฒดํฌ | ||
answer = set(uniqueKeys) | ||
print(answer) | ||
for i in range(len(uniqueKeys)): | ||
for j in range(i + 1, len(uniqueKeys)): | ||
if set(uniqueKeys[i]) & set(uniqueKeys[j]) == set(uniqueKeys[i]): | ||
answer.discard(uniqueKeys[j]) | ||
|
||
return len(answer) | ||
|
||
|
||
print(solution([["100", "ryan", "music", "2"], ["200", "apeach", "math", "2"], ["300", "tube", "computer", "3"], | ||
["400", "con", "computer", "4"], ["500", "muzi", "music", "3"], ["600", "apeach", "music", "2"]])) |
13 changes: 13 additions & 0 deletions
13
JeonHyoChang/Season2/23.08.25 ์นด์นด์ค 2๋ฌธ์ /๋ ๊ฐ ๋ฝ์์ ๋ํ๊ธฐ.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
def solution(numbers): | ||
answer = set() | ||
|
||
for i in range(len(numbers)): | ||
for j in range(i + 1, len(numbers)): | ||
answer.add(numbers[i] + numbers[j]) | ||
answer = list(answer) | ||
answer.sort() | ||
return answer | ||
|
||
|
||
print(solution([2, 1, 3, 4, 1])) | ||
print(solution(([5, 0, 2, 7]))) |
34 changes: 34 additions & 0 deletions
34
JeonHyoChang/Season2/23.08.25 ์นด์นด์ค 2๋ฌธ์ /๋ฌธ์์ด ์์ถ.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
def combine(c, s): | ||
if c != 1: | ||
return str(c) + s | ||
return s | ||
|
||
|
||
def solution(s): | ||
answer = s | ||
|
||
for i in range(1, len(s) // 2 + 1): | ||
tempStr = "" | ||
startStr = s[0:i] | ||
count = 1 | ||
for j in range(i, len(s), i): | ||
if s[j:j + i] == startStr: | ||
count += 1 | ||
else: | ||
tempStr += combine(count, startStr) | ||
startStr = s[j:j + i] | ||
count = 1 | ||
tempStr += combine(count, startStr) | ||
print(tempStr) | ||
if len(answer) > len(tempStr) or i == 1: | ||
answer = tempStr | ||
|
||
return len(answer) | ||
|
||
|
||
# print(solution("aabbaccc")) | ||
# print(solution("ababcdcdababcdcd")) | ||
# print(solution("abcabcdede")) | ||
# print(solution("abcabcabcabcdededededede")) | ||
# print(solution("xababcdcdababcdcd")) | ||
# print(solution("a")) |