Skip to content

Commit

Permalink
[#3] 2021.12.17 벡준단계별7. 문자열
Browse files Browse the repository at this point in the history
  • Loading branch information
hyesuuou committed Dec 18, 2021
1 parent f616c63 commit e9e7fbf
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Boj/문자열/10809.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
s = input()
alphabet = []

for i in range(0, 26):
alphabet.append(-1)

for i in range(len(s)):
if alphabet[ord(s[i])-97] == -1:
alphabet[ord(s[i])-97] = i


for i in range(len(alphabet)):
print(alphabet[i], end=" ")
29 changes: 29 additions & 0 deletions Boj/문자열/1152.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
str = input()
alphabet = []

for i in range(26):
alphabet.append(0)

# 알파벳 개수 세기
for i in str:
if ord(i) >= 97:
alphabet[ord(i)-97] = alphabet[ord(i)-97] + 1
else:
alphabet[ord(i)-65] = alphabet[ord(i)-65] + 1

# 가장 많은 알파벳 대문자로 출력하기
max = 0
maxIdx = -1
for i in range(len(alphabet)):
if max < alphabet[i]:
max = alphabet[i]
maxIdx = i

for i in range(len(alphabet)):
if i != maxIdx and max == alphabet[i]:
max = -1

if max == -1:
print("?")
else:
print(chr(maxIdx + 65))
29 changes: 29 additions & 0 deletions Boj/문자열/1157.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
str = input()
alphabet = []

for i in range(26):
alphabet.append(0)

# 알파벳 개수 세기
for i in str:
if ord(i) >= 97:
alphabet[ord(i)-97] = alphabet[ord(i)-97] + 1
else:
alphabet[ord(i)-65] = alphabet[ord(i)-65] + 1

# 가장 많은 알파벳 대문자로 출력하기
max = 0
maxIdx = -1
for i in range(len(alphabet)):
if max < alphabet[i]:
max = alphabet[i]
maxIdx = i

for i in range(len(alphabet)):
if i != maxIdx and max == alphabet[i]:
max = -1

if max == -1:
print("?")
else:
print(chr(maxIdx + 65))
2 changes: 2 additions & 0 deletions Boj/문자열/11654.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
n = input()
print(ord(n))
6 changes: 6 additions & 0 deletions Boj/문자열/11720.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
n = int(input())
data = input()
sum = 0
for i in data:
sum = sum + int(i)
print(sum)
29 changes: 29 additions & 0 deletions Boj/문자열/1316.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
n = int(input()) # 소문자 단어

# 단어 입력받기
wordList = []
for i in range(n):
wordList.append(input())

# 그룹단어 체크하는 함수 True/False
def checkGroup(word):
alphabet = []
for i in range(26):
alphabet.append(0)

alphabet[ord(word[0])-97] = alphabet[ord(word[0])-97] + 1

for i in range(1, len(word)):
if word[i] != word[i-1] and alphabet[ord(word[i])-97] != 0:
return False
else:
alphabet[ord(word[i]) - 97] = alphabet[ord(word[i])-97] + 1
return True

result = 0

for i in range(len(wordList)):
if checkGroup(wordList[i]) == True:
result = result + 1

print(result)
8 changes: 8 additions & 0 deletions Boj/문자열/2675.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
t = int(input())

for i in range(t):
r, s = input().split()
r = int(r)
for j in s:
print(j*r, end="")
print()
9 changes: 9 additions & 0 deletions Boj/문자열/2908.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
a, b = map(int, input().split())

a = (a % 10)*100 + (a//10%10) * 10 + (a//100)
b = (b % 10)*100 + (b//10%10) * 10 + (b//100)

if a > b:
print(a)
else:
print(b)
7 changes: 7 additions & 0 deletions Boj/문자열/2941.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
word = input() # 알파벳 소문자, - = 로만 이루어져 있는 최대 100글자 단어
list = ['c=', 'c-', 'dz=', 'd-', 'lj', 'nj', 's=', 'z=']

for i in range(len(list)):
word = word.replace(list[i], '1')

print(len(word))
22 changes: 22 additions & 0 deletions Boj/문자열/5622.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
w = input()
ans = 0

for i in w:
if i <= 'C':
ans = ans + 3
elif i <= 'F':
ans = ans + 4
elif i <= 'I':
ans = ans + 5
elif i <= 'L':
ans = ans + 6
elif i <= 'O':
ans = ans + 7
elif i <= 'S':
ans = ans + 8
elif i <= 'V':
ans = ans + 9
else:
ans = ans + 10

print(ans)

0 comments on commit e9e7fbf

Please sign in to comment.