-
[9536] 여우는 어떻게 울지? (Python)[Python] 알고리즘/Silver 2021. 10. 28. 17:06
[문제]
https://www.acmicpc.net/problem/9536
알고리즘 분류는 문자열, 파싱 입니다.
set()을 이용하면, 섞여있는 울음소리 - 여우를 제외한 울음소리 = 여우의 울음소리를 얻을 수 있습니다.
set()은 중복된 것을 없애므로 완벽한 여우의 울음소리는 아닙니다.
[코드]
import sys T = int(sys.stdin.readline()) for i in range(T): sound = sys.stdin.readline().split() animal_sound = list() while True: animal = sys.stdin.readline().rstrip() if animal == "what does the fox say?": break else: animal_sound.append(animal.split()[2]) fox = list(set(sound) - set(animal_sound)) for j in sound: if j in fox: print(j, end=" ")
'[Python] 알고리즘 > Silver' 카테고리의 다른 글
[5648] 역원소 정렬 (Python) (0) 2021.11.02 [1935] 후위 표기식2 (Python) (0) 2021.11.01 [11478] 서로 다른 부분 문자열의 개수 (Python) (0) 2021.10.31 [10815] 숫자 카드 (Python) (0) 2021.10.29 [9414] 프로그래밍 대회 전용 부지 (Python) (0) 2021.10.27