지나가던 개발자
[Python] 백준 1411번(비슷한 단어) 문제 풀이 본문
from itertools import combinations
def is_similar(s1, s2):
similar = []
for i in [s1, s2]:
alpha = []
a = ""
for j in i:
if j not in alpha:
alpha.append(j)
a += str(alpha.index(j))
similar.append(a)
if len(set(similar)) == 1:
return True
return False
ans = 0
for i in combinations([input() for i in range(int(input()))], 2):
if is_similar(i[0], i[1]):
ans += 1
print(ans)
저번에 64일 스트릭이 깨진 뒤에 우울해서 한동안 백준을 안 풀었다.
이제 다시 시작해봐야겠다... 물론 스트릭을 시작하는 건 아니고 백준풀이를 좀 해야겠다는거다. 신년 목표 중 백준 골드2 찍기가 있다.
'PS > Python' 카테고리의 다른 글
[Python] 백준 17219번(비밀번호 찾기) 문제 풀이 (0) | 2023.01.10 |
---|---|
[Python] NYPC 2022 Round 1 인류의 적 모기 퇴치 문제 풀이 (0) | 2023.01.04 |
[Python] 백준 3986번(좋은 단어) 문제 풀이 (0) | 2022.12.12 |
[Python] 백준 11899번(괄호 끼워넣기) 문제 풀이 (0) | 2022.12.11 |
[Python] 백준 13235번(팰린드롬) 문제 풀이 (0) | 2022.12.10 |
Comments