백준 [ALGORITHM] - 명령 프롬프트 (1032)

2023. 6. 11. 20:26코딩/백준 [ALGORITHM]

반응형
n = int(input())

lst = [] 
passlist = []
place = []

for i in range(n):
    text = input()
    lst.append(text)

if n == 1:
    print(text)
    exit()
else:
    for i in range(len(lst)-1):
        for j in range(len(lst[i])):
            if lst[i][j] != lst[i+1][j]:
                temp = list(lst[i])
                temp.pop(j)
                temp.insert(j,'?')
                passlist.append(temp)
for i in range(len(passlist)):
    if '?' in passlist[i]:
        place.append(str(passlist[i]).index('?'))
    else:
        pass

text = list(text)

for i in range(len(passlist)):
        place = ''.join(passlist[i-1])
        x = place.find('?')
        text[x] = '?'
print(''.join(text))

코드가 더럽다

반응형