알고리즘1 알고리즘 001 한 반에 100명이 참여하는 수업이 있다. 여기서 같은 생일을 가진 사람이 2명 이상일 확률은 얼마나 될까? 나의 풀이. 먼저 100명의 생일 데이터를 월별로 분류한다. 그리고 난 후, 날짜별로 오름차순으로 정리한다. 이렇게 되면 보다 쉽게 같은 생일을 가진 사람들을 찾을 수 있다. 슈도코드 import random def find_duplicate_birthdays(k): birthdays = [random.randint(1, 365) for i in range(k)] birthday_counts = {} for birthday in birthdays: if birthday not in birthday_counts: birthday_counts[birthday] = 1 else: birthday_cou.. 2023. 3. 6. 이전 1 다음