1. Problem
2. My Solution
import sys
while(True):
try:
sentence = sys.stdin.readline()
result = [0] * 4
for i in sentence:
if 'a' <= i <= 'z':
result[0] += 1
elif 'A' <= i <= 'Z':
result[1] += 1
elif i == ' ':
result[3] += 1
else:
result[2] += 1
result[2] -= 1
print(' '.join(map(str,result)))
except EOFError:
break
3. Others' Solutions
import sys
while(True):
sentence = sys.stdin.readline().rstrip('\n')
result = [0] * 4
if not sentence: # None 이면 break
break
for i in sentence:
if i.islower():
result[0] += 1
elif i.isupper():
result[1] += 1
elif i.isdigit():
result[2] += 1
elif i.isspace():
result[3] += 1
print(' '.join(map(str,result)))
4. Learned
1. Problem
2. My Solution
import sys
sentence = sys.stdin.readline().strip().split()
result = []
for word in sentence:
temp =''
for char in word:
if char.isdigit():
temp += str(char)
elif char.islower():
temp += chr((((ord(char) - 97) + 13) % 26)+97)
elif char.isupper():
temp += chr((((ord(char) - 65 ) + 13) % 26)+65)
result.append(temp)
print(' '.join(result))
mport sys
sentence = sys.stdin.readline().rstrip()
result = ''
for char in sentence:
if char.isdigit():
result += str(char)
elif char.islower():
result += chr((((ord(char) - 97) + 13) % 26)+97)
elif char.isupper():
result += chr((((ord(char) - 65 ) + 13) % 26)+65)
elif char.isspace():
result += ' '
print(result)
3. Learned
1. Problem
2. My Solution
import sys
a,b = map(int,sys.stdin.readline().rstrip().split())
max_num = 0
min_num = 0
i = min(a,b)
while(i > 0):
if a % i == 0 and b % i ==0:
max_num = i
break
i = min(a,b)//max_num
while(True):
if max_num * i % a == 0 and max_num * i % b ==0:
min_num = max_num * i
break
else:
i += 1
print(max_num)
print(min_num)
import sys
a,b = map(int,sys.stdin.readline().rstrip().split())
i = min(a,b)
while(i > 0):
if a % i == 0 and b % i ==0:
max_num = i
break
else:
i -= 1
min_num = a*b // max_num
print(max_num)
print(min_num)
3. Learned