[백준/Python] 5597) 과제 안 내신 분..?

Jimin_Note·1일 전
0

[백준/Python]

목록 보기
22/25
post-thumbnail

✨ 2025.06.11 코딩테스트 문제 풀이

📌 문제: 과제 안 내신 분..?

🧠 문제 설명

  • 총 30명의 학생 중 28명만 과제를 제출
  • 입력으로 28명의 출석번호가 중복없이 주어진다.
  • 과제를 제출하지 않은 2명의 출석번호를 오름차순으로 출력

💻 내가 작성한 코드

import sys

submitted_students = [int(sys.stdin.readline()) for _ in range(28)] # 엔터로 28번 입력받기
missing = sorted(set(range(1, 31)) - set(submitted_students))
for student in missing:
    print(student)

✅ 배운 점

  • [1, 2, 3] - [2, 3]TypeError : 리스트는 이런 연산 불가능
  • set(range(1, 31)) - set(submitted_students) : {1, 2, 3} - {2, 3} = {1} 집합으로 변환해서 차집합을 구해야함

🧩 회고

list - list는 안 되지만, set - set은 가능!!

profile
Hello. I'm jimin:)

0개의 댓글