https://www.acmicpc.net/problem/1032
1032번: 명령 프롬프트
첫째 줄에 파일 이름의 개수 N이 주어진다. 둘째 줄부터 N개의 줄에는 파일 이름이 주어진다. N은 50보다 작거나 같은 자연수이고 파일 이름의 길이는 모두 같고 길이는 최대 50이다. 파일이름은
www.acmicpc.net
난이도: 브론즈1
소요시간:15분
아래는 나의 코드이다.
import sys
N= int(sys.stdin.readline())
inputList=[]
for i in range(N):
inputList.append(str(sys.stdin.readline().rstrip()))
result=""
for i in range(len(inputList[0])):
count=1
for j in range(N-1):
if inputList[j][i]==inputList[j+1][i]:
count+=1
if count == N:
result+=inputList[0][i]
else:
result+='?'
print(result)
아래코드는 다른사람의 코드인데 아이디어가 좋고 간단하다.
n = int(input())
a = list(input())
a_len = len(a)
for i in range(n - 1):
b = list(input())
for j in range(a_len):
if a[j] != b[j]:
a[j] = '?'
print(''.join(a))
'Problem Solving > 구현' 카테고리의 다른 글
kakao2018 셔틀버스(R) (0) | 2023.04.12 |
---|---|
BOJ2504 괄호의 값 (R) (0) | 2023.04.07 |
BOJ1138 한 줄로 서기 (0) | 2023.03.28 |
게임 개발 (0) | 2022.12.29 |
왕실의 나이트 (0) | 2022.12.29 |