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

Home > Numbers
Four generations (Posted on 2020-07-06) Difficulty: 3 of 5
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 ?

Explain your way of reasoning.

No Solution Yet Submitted by Ady TZIDON    
Rating: 3.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 2 of 9 |
The program:

DefDbl A-Z
Dim crlf$
 
Private Sub Form_Load()
 Text1.Text = ""
 crlf$ = Chr(13) + Chr(10)
 Form1.Visible = True
  
  st = Int(100000 / 143) * 143
  
  Text1.Text = Text1.Text & st & crlf
  
  n = st
  Do
    n = n + 143
    ns$ = LTrim(Str(n))
    lowest = 999
    highest = -1
    For i = 1 To Len(ns)
      If Val(Mid(ns, i, 1)) < lowest Then lowest = Val(Mid(ns, i, 1))
      If Val(Mid(ns, i, 1)) > highest Then highest = Val(Mid(ns, i, 1))
    Next
    If highest - lowest = 5 Then ct = ct + 1: lastmemb = n
  Loop Until n > 999999
  
  
  Text1.Text = Text1.Text & ct & Str(lastmemb) & " done"
  DoEvents

End Sub


has output:

99957
542 997854 done

meaning 

99957 is the last multiple of 143 that's less than 6 digits.

542 is the sought cardinality.

997854 is the last multiple of 143 that meets the other criteria.


The subsets were chosen in reverse order to make the search more efficient: only multiples of 143 were tested; the starting point was arrived at by division, so as few numbers as possible were tested to see if the middle criterion was true, concerning the difference between highest and lowest digits.

  Posted by Charlie on 2020-07-06 10:15:25
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (0)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information