Find the number of sets A such that A ⊂ {1, 2, 4, 5, 6, 8, 9, 10, 11}, |A| = 4 and A contains no consecutive integers.
29
----
from itertools import combinations
A = [1, 2, 4, 5, 6, 8, 9, 10, 11]
count = 0
for comb in combinations(A,4):
x = sorted(list(comb))
fail = False
for i in range(1,4):
if x[i]-x[i-1] == 1:
fail = True
if fail:
continue
count += 1
print(count)
|
Posted by Larry
on 2025-02-13 09:26:40 |