3003
원래는 if-else문을 반복 했다가 복잡해지고 틀린 것을 알게 됨.
-> 수정
pieces = [1, 1, 2, 2, 2, 8]
k, q, l, b, kn, p = map(int, input().split())
current = [k, q, l, b, kn, p]
result = [pieces[i] - current[i] for i in range(6)]
print(*result)
# 2444
n = int(input())
for i in range(1,n+1):
print(" "*(n-i) + "*"*(2*i-1))
for j in range(n-1,0,-1):
print(" "*(n-j) + "*"*(2*j-1))
10988
word = input()
i = 0
res = 1
while i <len(word)//2:
if word[i] == word[len(word)-i-1]:
i +=1
else:
res=0
break
print(res)
-> 내가 짠 코드
너 간단하게
word = input()
print(1 if word == word [::-1] else 0)
1157
dic={}
word = input().upper()
for w in word:
if w not in dic.keys():
dic[w] = 1
else:
dic[w] +=1
j = 0
for w in word:
if dic[w] >= max(dic.values()):
res = w
j+=1
print(res if j <=1 else "?")
2941
replace 함수를 이용하는 문제 -> 못 풀었음
letter = input()
cro = ['c=', 'c-', 'dz=', 'd-', 'lj', 'nj', 's=', 'z=']
for i in cro:
letter= letter.replace(i,"*")
print(len(letter))

1316
count = 0
n = int(input())
for _ in range(n):
word = input()
newList = []
isGroup = True
for j in range(len(word)):
if word[j] not in newList:
newList.append(word[j])
elif word[j] == word[j-1]:
continue
else:
isGroup = False
break
if isGroup:
count += 1
print(count)
25206
credit = {
'A+':4.5, 'A0':4.0,
'B+':3.5, 'B0':3.0,
'C+':2.5, 'C0':2.0,
'D+':1.5, 'D0':1.0,
'F':0.0
}
total_score = 0.0
total_credit = 0.0
for _ in range(20):
a, b, c = input().split()
b = float(b)
if c != 'P':
total_score += b * credit[c]
total_credit += b
print(total_score / total_credit)
'코딩 테스트 > Python' 카테고리의 다른 글
| 백준, Python) 2차원 배열 2566, 10798, 2563 (0) | 2025.04.16 |
|---|---|
| 백준, Python) 10809, 2675, 2908, 5622, 11718 (0) | 2025.04.09 |
| 백준, Python) 10870, 10871, 5597 (0) | 2025.04.08 |
| 백준, Python) 15552, 10951 (0) | 2025.04.07 |
| 백준, Python) 2단계 2525, 2480 (0) | 2025.04.04 |