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

 Self-Referential Numbers (Posted on 2005-09-23)
A nine digit number has the property where the first digit equals the number of zeros and ones used in the number, the second digit equals the number of ones and twos used in the number, the third digit equals the number of twos and threes used in the number, etc. through the ninth digit equals the number of eights and nines used in the number. What could the number be?

A ten digit number has a similar property to the nine digit number. The first digit equals the number of zeros and ones used in the number, the second digit equals the number of ones and twos used in the number, etc. through the ninth digit. And also, the tenth digit equals the number of zeros and nines used in the number. What could this number be?

 See The Solution Submitted by Brian Smith Rating: 3.4000 (5 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 re(3): Attn: Ken Haley | Comment 12 of 17 |
(In reply to re(2): Attn: Ken Haley by Charlie)

In fact, the following VB 5.0 form for doing part 1 followed by part 2, when the command button is pressed, typically reports 2 seconds, sometimes 1 second difference between start and end times, so it must be something like 1.8 or 1.9 seconds (on a 2 GHz machine):

VERSION 5.00
Begin VB.Form Form1
Caption         =   "Form1"
ClientHeight    =   5235
ClientLeft      =   60
ClientTop       =   450
ClientWidth     =   9105
ScaleHeight     =   5235
ScaleWidth      =   9105
StartUpPosition =   3  'Windows Default
Begin VB.CommandButton Command1
Caption         =   "Command1"
Height          =   495
Left            =   6360
TabIndex        =   0
Top             =   600
Width           =   1935
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim ct(11), d(11), noDigs, tOfDigs, rejCt

Private Sub Command1_Click()

Cls

noDigs = 0

Print Time

noDigs = 0

Print Time

End Sub

Max = 20 - tOfDigs
If Max > 9 Then Max = 9
For i = 0 To Max
' IF noDigs = 1 THEN PRINT i
If noDigs Or i Then
good = 1
noDigs = noDigs + 1
tOfDigs = tOfDigs + i
d(noDigs) = i
ct(i) = ct(i) + 1
ct(i + 1) = ct(i + 1) + 1
cts1 = ct(i)
cts2 = ct(i + 1)
If i <= noDigs Then
If cts1 > d(i) And i > 0 Then
good = 0
End If
End If
If i + 1 <= noDigs Then
If cts2 > d(i + 1) Then
good = 0
End If
End If

If good Then
If noDigs = 9 Then
For j = 1 To 9
If d(j) <> ct(j) Then good = 0
Next
If good Then
For j = 1 To 9
Print d(j);
Next
Print
End If
Else
If tOfDigs < 18 Then
End If

End If
End If
noDigs = noDigs - 1
tOfDigs = tOfDigs - i
ct(i) = ct(i) - 1
ct(i + 1) = ct(i + 1) - 1
End If
Next
End Sub

Max = 20 - tOfDigs
If Max > 9 Then Max = 9
For i = 0 To Max
If noDigs Or i Then
good = 1
noDigs = noDigs + 1
tOfDigs = tOfDigs + i
d(noDigs) = i
Select Case i
Case 0
ia = 10
ib = 1
Case 9
ia = 9
ib = 10
Case Else
ia = i
ib = i + 1
End Select
ct(ia) = ct(ia) + 1
ct(ib) = ct(ib) + 1
cts1 = ct(ia)
cts2 = ct(ib)
If ia <= noDigs Then
If cts1 > d(ia) And ia > 0 Then
good = 0
End If
End If
If ib <= noDigs Then
If cts2 > d(ib) Then
good = 0
End If
End If

If good Then
If noDigs = 10 Then
For j = 1 To 10
If d(j) <> ct(j) Then good = 0
Next
If good Then
For j = 1 To 10
Print d(j);
Next
Print
End If
Else
If tOfDigs < 18 Then
End If

End If
End If
noDigs = noDigs - 1
tOfDigs = tOfDigs - i
ct(ia) = ct(ia) - 1
ct(ib) = ct(ib) - 1
End If
Next
End Sub

 Posted by Charlie on 2005-09-24 16:06:47

 Search: Search body:
Forums (0)