All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Four generations (Posted on 2020-07-06)
Let S be a set of all six-digit 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 ?

Comments: ( Back to comment list | You must be logged in to post comments.)
 Better late than never. Computer solution Comment 9 of 9 |
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 2020-07-07 08:39:15

 Search: Search body:
Forums (0)