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.)
Solution Computer program solution | Comment 2 of 19 |
Three 9 digit numbers:
 
533211000
542121000
740110110
 
One 10 digit number
 
4224400004
 
--------------------------------------------------------------------------
The following "short" VB program found both numbers in 12 seconds.
 
Option Strict On
Imports System
Imports System.IO
Imports System.Text
Imports System.Runtime.InteropServices
Imports System.Math
Module Module1
    Dim number(10) As Integer
    Sub Main()
        Randomize()
        Dim interval As Double = 0
        Dim quit As String
        Console.WriteLine( _
        "Start: " & TimeOfDay)
        For index0 As Integer = 0 To 9
            For index1 As Integer = 0 To 9
                If index0 _
                + index1 <= 20 Then
                    For index2 As Integer = 0 To 9
                        If index0 _
                        + index1 _
                        + index2 <= 20 Then
                            For index3 As Integer = 0 To 9
                                If index0 _
                                + index1 _
                                + index2 _
                                + index3 <= 20 Then
                                    For index4 As Integer = 0 To 9
                                        If index0 _
                                        + index1 _
                                        + index2 _
                                        + index3 _
                                        + index4 <= 20 Then
                                            For index5 As Integer = 0 To 9
                                                If index0 _
                                                + index1 _
                                                + index2 _
                                                + index3 _
                                                + index4 _
                                                + index5 <= 20 Then
                                                    For index6 As Integer = 0 To 9
                                                        If index0 _
                                                        + index1 _
                                                        + index2 _
                                                        + index3 _
                                                        + index4 _
                                                        + index5 _
                                                        + index6 <= 20 Then
                                                            For index7 As Integer = 0 To 9
                                                                If index0 _
                                                                + index1 _
                                                                + index2 _
                                                                + index3 _
                                                                + index4 _
                                                                + index5 _
                                                                + index6 _
                                                                + index7 <= 20 Then
                                                                    For index8 As Integer = 0 To 9
                                                                        number(0) = index0
                                                                        number(1) = index1
                                                                        number(2) = index2
                                                                        number(3) = index3
                                                                        number(4) = index4
                                                                        number(5) = index5
                                                                        number(6) = index6
                                                                        number(7) = index7
                                                                        number(8) = index8
                                                                        number(9) = 0
                                                                        check_number9()
                                                                        If index0 _
                                                                        + index1 _
                                                                        + index2 _
                                                                        + index3 _
                                                                        + index4 _
                                                                        + index5 _
                                                                        + index6 _
                                                                        + index7 _
                                                                        + index8 <= 20 Then
                                                                            For index9 As Integer = 0 To 9
                                                                                If index0 _
                                                                                + index1 _
                                                                                + index2 _
                                                                                + index3 _
                                                                                + index4 _
                                                                                + index5 _
                                                                                + index6 _
                                                                                + index7 _
                                                                                + index8 _
                                                                                + index9 = 20 Then
                                                                                    number(9) = index9
                                                                                    check_number10()
                                                                                End If
                                                                            Next
                                                                        End If
                                                                    Next
                                                                End If
                                                            Next
                                                        End If
                                                    Next
                                                End If
                                            Next
                                        End If
                                    Next
                                End If
                            Next
                        End If
                    Next
                End If
            Next
        Next
        Console.WriteLine( _
        "End: " & TimeOfDay)
        quit = "?"
        While quit <> "x"
            Console.WriteLine("Enter x to exit")
            quit = LCase(Console.ReadLine())
        End While
    End Sub
   
    Sub check_number10()
        Dim count10(10) As Integer
        Dim sub1 As Integer
        Dim string0 As String
        For index1 As Integer = 0 To 9
            count10(index1) = 0
        Next
        For index1 As Integer = 0 To 9
            count10(number(index1)) += 1
        Next
        For index1 As Integer = 0 To 8
            If number(index1) <> _
            count10(index1) + count10(index1 + 1) Then
                Exit Sub
            End If
        Next
        If number(9) <> count10(9) + count10(0) Then
            Exit Sub
        End If
        Console.WriteLine("Answer for 10 digit number:")
        string0 = ""
        For index1 As Integer = 0 To 9
            string0 &= Str(number(index1))
        Next
        Console.WriteLine(string0)
    End Sub
   
    Sub check_number9()
        Dim count9(10) As Integer
        Dim sub1 As Integer
        Dim string0 As String
        For index1 As Integer = 0 To 9
            count9(index1) = 0
        Next
        For index1 As Integer = 0 To 8
            count9(number(index1)) += 1
        Next
        For index1 As Integer = 0 To 8
            If number(index1) <> _
            count9(index1) + count9(index1 + 1) Then
                Exit Sub
            End If
        Next
        Console.WriteLine("Answer for 9 digit number:")
        string0 = ""
        For index1 As Integer = 0 To 8
            string0 &= Str(number(index1))
        Next
        Console.WriteLine(string0)
    End Sub
End Module
 
 

Edited on September 24, 2005, 11:35 am
  Posted by Penny on 2005-09-23 19:36:29

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (1)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (23)
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