반응형
https://www.acmicpc.net/problem/2870
방법 1. 소문자 없애기
import re
n = int(input())
p = re.compile('[a-z]')
answer = []
for _ in range(n):
result = p.sub(' ', input()).split()
for x in result:
answer.append(int(x))
answer.sort()
for i in range(len(answer)):
print(answer[i])
방법 2. 숫자 바로 탐색
import re
n = int(input())
p = re.compile('[0-9]+') # /d로 [0-9]를 표현 가능
answer = []
for _ in range(n):
result = p.findall(input())
for x in result:
answer.append(int(x))
answer.sort()
for i in range(len(answer)):
print(answer[i])
댓글