관리 메뉴

솜씨좋은장씨

[BaekJoon] 10815번 : 숫자 카드 (Python) 본문

Programming/코딩 1일 1문제

[BaekJoon] 10815번 : 숫자 카드 (Python)

솜씨좋은장씨 2021. 10. 23. 13:58
728x90
반응형

👨🏻‍💻 코드 ( Solution )

import sys

def make_answer(answer, check_dict, temp):
    try:
        check = check_dict[temp]
        temp = ""
        answer.append("1")
    except:
        answer.append("0")
        temp = ""
        
    return answer, temp


def number_card(my_numbers, check_numbers):
    answer = []
    check_dict = {}
    temp = ""
    for num in my_numbers:
        if num.isdigit() or num == "-":
            temp += num
        elif num == " ":
            check_dict[temp] = 0
            temp = ""
    check_dict[temp] = 0
    temp = ""    
    for num in check_numbers:
        if num.isdigit() or num == "-":
            temp += num
        elif num == " ":
            answer, temp = make_answer(answer, check_dict, temp)

    if temp != "":
        answer, temp = make_answer(answer, check_dict, temp)
            
    return " ".join(answer)

if __name__ == "__main__":
    N = int(input())
    my_numbers = input()
    M = int(input())
    check_numbers = input()
    print(number_card(my_numbers, check_numbers))
 

GitHub - SOMJANG/CODINGTEST_PRACTICE: 1일 1문제 since 2020.02.07

1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub.

github.com

Comments