선릉역 1번 출구
baekjoon - 문자열 본문
1. 11654
print(ord(input())) |
2. 11720
a = int(input()) b = input() sum = 0 for i in range(a): sum += int(b[i]) print(sum) |
a = int(input()) b = input() print(sum([int(i) for i in b])) |
3. 10809
ls = [-1] * 26 word = input() for i in range(len(word)): if ls[ord(word[i])-97] == -1: ls[ord(word[i])-97] = i for i in range(26): print("{} ".format(ls[i]), end="") // print(f'{a[i]} ',end='') |
4. 2675
for _ in range(int(input())): a = input().split() key = int(a[0]) word = a[1] new_word = "" for i in range(len(word)): new_word += word[i] * key print(new_word) |
5. 1157
a = input().lower() ls = [0] * 26 for i in range(26): key = chr(i+97) ls[i] = a.count(key) if ls.count(max(ls)) == 1: print(chr(ls.index(max(ls))+65)) else: print("?") |
#count, index()
6. 1152
a = input().split() print(len(a)) |
7. 2908
a = input().split() num1 = int(a[0][::-1]) num2 = int(a[1][::-1]) if num1 < num2: print(num2) else: print(num1) |
#slice
8. 5622
a = {"A":2, "B":2, "C":2, "D":3, "E":3, "F":3, "G":4, "H":4,"I":4, "J":5, "K":5, "L":5, "M":6, "N":6, "O":6, "P":7, "Q":7, "R":7 , "S":7, "T":8, "U":8, "V":8, "W":9, "X":9, "Y":9, "Z":9} b = input() sum = 0 for i in range(len(b)): sum += a[b[i]]+1 print(sum) |
#dictionary study
9. 2941
a = input() b = ["dz=", "c=", "c-", "d-", "lj", "nj", "s=", "z="] for i in range(8): a = a.replace(b[i],"!") print(len(a)) |
10. 1316
n = int(input()) sum = 0 dir = [0]*26 for i in range(n): word = input().upper() for j in range(1,len(word)): if word[j-1] != word[j]: if set(word[:j]) == set(word[:j+1]): sum += 1 break sum = n - sum print(sum) |
count = int(input()) for _ in range(count): a = input() b = [0] * 26 flag = 1 for i in range(len(a)-1): if a[i] != a[i+1]: if b[ord(a[i]) - 97] == 0: b[ord(a[i]) - 97] = 1 else: count -= 1 flag = 0 break if flag == 1: if b[ord(a[len(a)-1]) - 97] == 1: count -= 1 print(count) |
'Algorithm > Algorithm 문제풀이' 카테고리의 다른 글
baekjoon - 기본 수학2 (0) | 2021.08.18 |
---|---|
baekjoon - 기본 수학1 (0) | 2021.08.17 |
baekjoon - 함수 (0) | 2021.08.17 |
baekjoon - 1차원 배열 (0) | 2021.08.17 |
baekjoon - while문 (0) | 2021.08.16 |
Comments