자기개발👨‍💻/코딩 알고리즘

[python] 백준 1032 명령프롬프트

천숭이 2021. 3. 10. 22:51

www.acmicpc.net/problem/1032

 

1032번: 명령 프롬프트

첫째 줄에 파일 이름의 개수 N이 주어진다. 둘째 줄부터 N개의 줄에는 파일 이름이 주어진다. N은 50보다 작거나 같은 자연수이고 파일 이름의 길이는 모두 같고 길이는 최대 50이다. 파일이름은

www.acmicpc.net

N=int(input())
oper = []
for i in range(N):
    oper.append(input())

index=[]
length = len(oper[0])
check=[1]*length
for i in range(length):
    for j in range(N):
        if str(oper[0])[i]!=str(oper[j])[i]:
            check[i]=0
            
    if 0 in check : 
        index.append("?")
    else: 
        index.append(str(oper[0])[i])
        
    check=[1]*length
    
for i in index:
    print(i,end="")

입력:

3

abc.txt

abc.gif

abc.aaa

 

출력:

abc.???