Skip to content
Open
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
21 changes: 21 additions & 0 deletions HyowonSin/season2/_230825/PGS_두개뽑아서더하기.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
def solution(numbers):
answer = set()

arr = sorted(numbers)
arr2 = set()

for i in range(len(arr)-1):
if arr[i] == arr[i+1]:
arr2.add(arr[i])

arr3 = list(set(arr))

for i in range(len(arr3)):
for j in range(i+1, len(arr3)):
num = arr3[i] + arr3[j]
answer.add(num)

for i in arr2:
answer.add(i+i)

return sorted(list(answer))
28 changes: 28 additions & 0 deletions HyowonSin/season2/_230825/PGS_문자열압축.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
def solution(s):
arr = []
for i in range(1, len(s) + 1):
index = 0
count = 1
temp = ""
while True:
if index+i >= len(s):
if count != 1:
temp += str(count)
temp += s[index:]
break
if s[index:index + i] == s[index + i:index + i + i]:
count += 1
else:
if count != 1:
temp += str(count)
temp += s[index:index+i]
count = 1
index += i
if index == len(s) - 1:
if count != 1:
temp += str(count)
temp += s[index]
break
arr.append(temp)
answer = min(map(lambda x: len(x), arr))
return answer