Results 1 to 4 of 4

Thread: Miles To Go...

  1. #1
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Dallas, Texas, USA
    Posts
    1,680
    Thanks
    0
    Thanked 1 Time in 1 Post

    Miles To Go...

    Tom was driving in his recently purchased SUV when he noticed that the odometer read precisely 12345.6 miles. What is truly amazing is that his trip odometer underneath read precisely 123.4 miles. <font color=blue>What is the smallest distance that Tom can drive so that the two odometers have all ten digits between them, but share no digits in common?</font color=blue>
    - Ricky

  2. #2
    4 Star Lounger
    Join Date
    Aug 2002
    Location
    Dallas, Texas, USA
    Posts
    594
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Miles To Go...

    Here's my answer: <span style="background-color: #FFFF00; color: #000000; font-weight: bold"><font color=yellow>861.1</font color=yellow></span hi>

    And more importantly, here's my method <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>:
    <span style="background-color: #FFFF00; color: #000000; font-weight: bold"><font color=yellow>
    Private Sub Command1_Click()
    Dim intTemp As Currency
    intTemp = 0.1
    Do Until CheckNumbers(intTemp) = True
    intTemp = intTemp + 1
    Loop
    MsgBox intTemp
    End Sub
    Function CheckNumbers(intTemp As Currency)
    Dim val1 As Currency
    Dim val2 As Currency
    Dim strTemp As String
    Dim blValid As Boolean
    Dim i As Long
    val1 = 12345.6 + intTemp
    val2 = 123.4 + intTemp
    strTemp = "" & val1 & val2
    strTemp = Replace(strTemp, ".", "")
    If Len(strTemp) <> 10 Then
    blValid = False
    Else
    blValid = True
    For i = 0 To 9
    If InStr(1, strTemp, "" & i, vbBinaryCompare) = 0 Then
    blValid = False
    Exit For
    End If
    Next i
    End If
    CheckNumbers = blValid
    End Function
    </font color=yellow></span hi>

    3 minutes to code, split second to run. Probably would have taken a LOT longer if I had tried to figure out an equation to solve it.

  3. #3
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Dallas, Texas, USA
    Posts
    1,680
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Miles To Go...

    Right, again! At that point his odometer would read <span style="background-color: #FFFF00; color: #000000; font-weight: bold"><font color=yellow>13206.7</font color=yellow></span hi> and the trip odometer will read <span style="background-color: #FFFF00; color: #000000; font-weight: bold"><font color=yellow>984.5</font color=yellow></span hi> miles. Nice job with the code. Wish I could do that. <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>
    - Ricky

  4. #4
    4 Star Lounger
    Join Date
    Aug 2002
    Location
    Dallas, Texas, USA
    Posts
    594
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Miles To Go...

    Actually, riddles like these would be a good way to learn to program. Programming is a lot more then just knowing what commands do what. To really become a good programmer, you need to be able to take a problem and figure out how to represent, and solve it with code.

    This one was fun.

    Drew

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •