Let S be a set of all sixdigit integers.
Let S1 be a subset of S, including all members of S such that each consists
of distinct digits.
Let S2 be a subset of S1, including all members of S1 each with 5 being the difference between its largest digit and its lowest one.
Let S3 be a subset of S2, comprising all elements of S2 divisible by 143.
What is the cardinality of S3 ?
Explain your way of reasoning.
Output of the Python program which follows is:
Cardinality of S: 900000
Cardinality of S1: 136080
Cardinality of S2: 3480
Cardinality of S3: 0

s0 = []
s1 = []
s2 = []
s3 = []
for i in range(100000,1000000):
s0.append(i)
if len(list(str(i))) == len(set(list(str(i)))): # because sets have no duplicate members
s1.append(i)
max_i = 1 # temporary
min_i = 11 # temporary
ilist = [int(c) for c in str(i)] # convert integer to list of digits
for j in ilist:
max_i = max(max_i,j)
min_i = min(min_i,j)
if max_i  min_i == 5:
s2.append(i)
if i % 143 == 0:
s3.append(i)
print('Cardinality of S: ',len(s0))
print('Cardinality of S1: ',len(s1))
print('Cardinality of S2: ',len(s2))
print('Cardinality of S3: ',len(s3))

Posted by Larry
on 20200707 08:39:15 