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

Home > Numbers
Self-Referential Numbers (Posted on 2005-09-23) Difficulty: 3 of 5
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
   LinkTopic       =   "Form1"
   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

addOn

noDigs = 0
addOnB

Print Time

End Sub

Sub addOn()
 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
      addOn
     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

Sub addOnB()
 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
      addOnB
     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
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 (9)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

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