Skip to content

Commit

Permalink
๐Ÿ”€merge: [230816] PGS ์‹คํŒจ์œจ, ํ›„๋ณดํ‚ค - 2๋ฌธ์ œ (#98)
Browse files Browse the repository at this point in the history
* โœจfeat: 8์›”16์ผ ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ๋ฌธ์ œ ํ’€์ด

* โœจfeat: 8์›”25์ผ PGS ๋ฌธ์ œ ํ’€์ด

์˜ค๋Š˜์€ ํž๋ง ๋Š๋‚Œ์œผ๋กœ ํ’€์ดํ–ˆ์Šต๋‹ˆ๋‹ค!
  • Loading branch information
JeonHyoChang committed Aug 30, 2023
1 parent 5a84784 commit b72ba4a
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 0 deletions.
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]))
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"]]))
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])))
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"))

0 comments on commit b72ba4a

Please sign in to comment.