[백준] 9935번 : 문자열 폭발

김개발·2021년 12월 19일
0

백준

목록 보기
75/75

문제 푼 날짜 : 2021-12-19

문제

문제 링크 : https://www.acmicpc.net/problem/9935

접근 및 풀이

cpp로 풀었던 이전 풀이와 비슷하게 완전탐색을 이용하여 풀어보았다.

코드

# 백준 9935번 : 문자열 폭발

if __name__ == "__main__":
    string = input()
    bomb = input()
    lst = []

    for ch in string:
        lst.append(ch)
        if ch == bomb[-1] and ''.join(lst[-len(bomb):]) == bomb:
            del lst[-len(bomb):]
    
    ans = ''.join(lst)

    if ans == '':
        print("FRULA")
    else:
        print(ans)

결과

피드백

join이라는 아주 유용한 함수를 알게 되었다.
아주 매력적인 언어인 것 같다.
진작에 공부를 할 걸...

profile
개발을 잘하고 싶은 사람

0개의 댓글