Skip to content

Commit

Permalink
🔀merge: [230809] PGS 다트게임, 뉴스클러스터링 - 2문제 (#94)
Browse files Browse the repository at this point in the history
* 🚚rename: 시즌1 문제풀이 디렉토리 이동

* ✨feat: 8월9일 프로그래머스 문제 풀이
  • Loading branch information
JeonHyoChang committed Aug 16, 2023
1 parent 865fa33 commit b2f1a46
Show file tree
Hide file tree
Showing 76 changed files with 57 additions and 0 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
def solution(str1, str2):
str1, str2 = str.upper(str1), str.upper(str2)
listStr1, listStr2 = [], []

for i in range(len(str1) - 1):
if str1[i].isalpha() and str1[i + 1].isalpha():
listStr1.append(str1[i:i + 2])
for i in range(len(str2) - 1):
if str2[i].isalpha() and str2[i + 1].isalpha():
listStr2.append(str2[i:i + 2])

if len(listStr1) + len(listStr2) == 0:
return 65536

count = 0
for x in listStr1:
if x in listStr2:
listStr2.remove(x)
count += 1

return int(count / (len(listStr1) + len(listStr2)) * 65536)


print(solution('FRANCE', 'french'))
print(solution('handshake', 'shake hands'))
print(solution('aa1+aa2', 'AAAA12'))
print(solution('E=M*C^2', 'e=m*c^2'))
30 changes: 30 additions & 0 deletions JeonHyoChang/Season2/23.08.09 카카오 2문제/다트 게임.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
def solution(dartResult):
result = []
tempScore = -1
for x in list(dartResult):
if x in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']:
if tempScore == 1 and x == '0':
tempScore = 10
else:
tempScore = int(x)
elif x in ['S', 'D', 'T']:
if x == 'D':
tempScore **= 2
elif x == 'T':
tempScore **= 3
result.append(tempScore)
tempScore = -1
else:
if x == '#':
result[len(result) - 1] *= -1
else:
if len(result) == 1:
result[0] *= 2
else:
result[len(result) - 1] *= 2
result[len(result) - 2] *= 2
return sum(result)


print(solution('1S2D*3T'))
print(solution('1D2S#10S'))

0 comments on commit b2f1a46

Please sign in to comment.