Code&Data Insights
BaekJoon Algorithm - Stage 7 [ 5-10 ] ( Python 3 ) 본문
BaekJoon Algorithm - Stage 7 [ 5-10 ] ( Python 3 )
paka_corn 2022. 1. 18. 06:55
2022.01.17
# 문자열 - stage 7
[2908]
[my code]
a,b = map(str,input().split())
a_new = int(a[2]+a[1]+a[0])
b_new = int(b[2]+b[1]+b[0])
if a_new > b_new:
print(a_new)
else:
print(b_new)
--> if else 대신 list/ join/ reversed 를 써서
max 함수로 풀수있음
** [::-1] 를 쓰면 문자열을 reverse 시킬 수 있음!
[new code]
a,b = input().split()
a = a[::-1]
b = b[::-1]
if a > b:
print(a)
else:
print(b)
----------------------------
[5622]
[my code]
dial = input()
dial_count = 0
for i in dial:
if i in "ABC":
dial_count += 3
elif i in "DEF":
dial_count += 4
elif i in "GHI":
dial_count += 5
elif i in "JKL":
dial_count += 6
elif i in "MNO":
dial_count += 7
elif i in "PQRS":
dial_count += 8
elif i in "TUV":
dial_count += 9
else:
dial_count += 10
print(dial_count)
--> if 문 안쓰고 더 간단하게 만드는법?
dial list를 만들수 있음
-------------------------
[1152]
[my code]
w = list(input().split())
print(len(w))
------------------------
[1157] , [2941],[1316] - 다시 풀어볼 것 ! *****
'Algorithm > BaekJoon Online Judge' 카테고리의 다른 글
BaekJoon Algorithm - Stage 8 [1712, 2869] ( Python 3 ) (0) | 2022.01.18 |
---|---|
BaekJoon Algorithm - Stage 1 ~ 7 [Review] (0) | 2022.01.18 |
BaekJoon Algorithm - Stage 6[1], Stage 7 [ 1-4 ] ( Python 3 ) (0) | 2022.01.16 |
BaekJoon Algorithm - Stage 5 [ 4-7 ] ( Python 3 ) (0) | 2022.01.15 |
BaekJoon Algorithm - Stage 4 [ 1-3 ], Stage 5 [ 1-3 ] ( Python 3 ) (0) | 2022.01.15 |