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

Home > Numbers
my house's number (Posted on 2004-06-21) Difficulty: 3 of 5
My house's number can be written as ABCD but it also equals to A^B * C^D. Find the number ..-no computer programs!!!

See The Solution Submitted by Ady TZIDON    
Rating: 4.5000 (4 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
re(2): Solution | Comment 7 of 32 |
(In reply to re: Solution by Richard)

I found it through a strict interpretation of Ady's admonition: "no computer programs!!!" That's "programs" (plural). I only used one program (singular). So I did not violate the letter of the law.  

"Always be true to your teeth, and they'll never be false to you." - Soupy Sales

Imports System
Imports System.Runtime.InteropServices
Imports System.Math
Module Module1
    Sub Main()
        Randomize()
        Dim strStartTime As String
        Dim strEndTime As String
        Dim strEnd As String
        Dim intArray(1000) As Integer
        Dim dblCount1 As Double = 0
        Dim dblCount2 As Double = 0
        strStartTime = TimeOfDay
        Console.WriteLine("Start of execution: " & strStartTime)
        For Index20 As Integer = 0 To 999
            intArray(Index20) = 0
        Next
        FindNumbers(intArray, dblCount1, dblCount2)
        Console.WriteLine("Found them ????")
        For Index21 As Integer = 0 To 999
            If intArray(Index21) = 0 Then
                Exit For
            End If
            Console.WriteLine(Str(intArray(Index21)))
        Next
        Console.WriteLine("Start of execution: " & strStartTime)
        strEndTime = TimeOfDay
        Console.WriteLine("End of execution: " & strEndTime)
        strEnd = "?"
        While strEnd <> "X"
            Console.WriteLine("Please enter X to exit program...")
            strEnd = UCase(Console.ReadLine())
        End While
    End Sub

    Sub FindNumbers(ByRef intArray, _
         ByRef dblCount1, ByRef dblCount2)
        IntervalBreak(dblCount1, dblCount2)
        For Index1 As Integer = 0 To 9
            For Index2 As Integer = 0 To 9
                For Index3 As Integer = 0 To 9
                    For Index4 As Integer = 0 To 9
                        TestNumbers(Index1, Index2, Index3, _
                        Index4, intArray)
                    Next
                Next
            Next
        Next
    End Sub
  

  Sub TestNumbers(ByRef Index1, ByRef Index2, ByRef Index3, _
    ByRef Index4, ByRef intArray)
        Dim dblNum1 As Double
        Dim dblNum2 As Double
        dblNum1 = Index4 + _
                  (10 * Index3) + _
                  (100 * Index2) + _
                  (1000 * Index1)
        dblNum2 = (Index1 ^ Index2) * _
                (Index3 ^ Index4)
        If dblNum1 = dblNum2 Then
            For Index6 As Integer = 0 To 999
                If intArray(Index6) = 0 Then
                    intArray(Index6) = dblNum1
                    Exit For
                End If
            Next
        End If
    End Sub


    Sub IntervalBreak(ByRef dblCount1, ByRef dblCount2)
        dblCount1 += 1
        dblCount2 += 1
        If dblCount1 > 49999 Then
            dblCount1 = 0
            Console.WriteLine("Now generating array number " & _
            Str(dblCount2))
        End If
    End Sub
End Module

 

 

Edited on June 21, 2004, 2:37 pm
  Posted by Penny on 2004-06-21 14:34:06

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 (3)
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