Skip to content

Instantly share code, notes, and snippets.

@junhoyeo
Created March 13, 2020 11:02
Show Gist options
  • Select an option

  • Save junhoyeo/f3d25cfedf9b32b8fba55edc34a3a5ed to your computer and use it in GitHub Desktop.

Select an option

Save junhoyeo/f3d25cfedf9b32b8fba55edc34a3a5ed to your computer and use it in GitHub Desktop.
1부터 10까지의 자연수가 각각 하나씩 적힌 구술 10개 중 4개를 선택할 때 3의 배수가 적힌 구슬이 적어도 한 개 선택되는 경우의 수
from itertools import combinations
marbles = list(range(1, 11))
combs = list(combinations(marbles, 4))
result = 0
for comb in combs:
if any(item % 3 == 0 for item in comb):
result += 1
print(result)
# 175
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment