« We arrived safely in Chicago | Main| How can you run multiple Sametime 7.5.x instances on the same machine? »

I haven't posted a puzzle in a while so here is a new one.

Category
Now travelling on our way back to New Hampshire, we were driving and I decided I was a little too old to play I spy, so I decided to come up with a mental challenge for Glen, it's almost a follow on to one of my previous puzzles, this is a more difficult challenge I believe. Here is the puzzle:

The car odometer, currently has two lines displayed, the Trip and the total mileage the car has driven, the numbers are:

Trip: 257.8
Odometer: 10845
The trip computer shows mileage to the nearest tenth, and the odometer shows mileage to the nearest mile. The trip computer resets to 0 at 1000 miles.

The questions are:
Q1. How many miles must be driven for the 4 Trip digits to match the last 4 digits of the odometer?
Q2. If the reset button on the trip was pressed and the trip reading returned to 000.0 would the mileage that needed to be driven for the four digits to match be more or less than the answer in Q1 and what would the odometer read.

Straght answers can be provided, and if you want to can also provide code that proves it. Have fun!

Glen claims to have an answer, but I have not verified it yet...

Update: Addtional Question
Q3. If I can press reset at any point on the trip reading after the current Odometer reading, what is the shortest mileage that can be driven to have the last 4 digits the same, and when should reset be pressed?

Comments

Gravatar Image1 - I think I got it....

Q1:
The mileage is 918.6. The meter readings are:
Odometer: 11764
Trip: 176.4

Q2: It will be more (1205 miles, to be exact)
Odometer: 12050
Trip: 205.0

Got some LotusScript and ducttape to proof my thinking. Shall I just copy/paste it here???

Gravatar Image2 - @1 Just paste away

Gravatar Image3 - Here it is! (Can't believe I was the only one? Am I right??)

Sub Click(Source As Button)
'the actual values:
Dim odometer As Double
Dim trip As Double
Dim mileCounter As Double

'Some counters
Dim tripCounter%

Dim compareOdometer$, compareTrip$ 'just the last four digits, without the decimals thingie

'Start values
odometer = 10845
trip = 257.8 'Change to 0 to proof Q2
compareOdometer = "0845"
compareTrip ="2578" 'Change to "0000" to proof Q2

While Not(compareOdometer = compareTrip)

For tripCounter = 1 To 10
mileCounter = Round(mileCounter,1) + 0.1 'rounding 'cause Lotusscript does some funnies...???
trip = Round(trip,1) + 0.1
odometer = Round(odometer,1) + 0.1

'counter resets to 0 after 999 miles
If trip = 1000 Then trip = 0

'Compare the two
compareOdometer = Right(Cstr(Round(odometer,0)),4)
compareTrip = Cstr(trip * 10)

If compareOdometer = compareTrip Then
Msgbox "Total mileage is " + Cstr(mileCounter) + ". The odometer is " + Cstr(Round(odometer,0)) + " and the trip is " + Cstr(trip)
End
End If
Next
Wend

End Sub


Gravatar Image4 - I did it in EXCEL ....

distance = INT ( (odometer_digits - trip_digits) * 0.111111111111...) * 10) / 10

The INT and (*10)/10 parts are to emulate the odometer's behavior of not advancing the units until the end of the 10ths cycle.

Thus ...
Q1 = INT ( (10845 - 2578) * 0.111111111 *10)/10 = 918.5
Q2 = INT ( (0845 - 0) * 0.111111111 *10)/10 = 1205.0

FYI - we reset the trip at odometer 10945 and they matched up at trip=105.0 and odometer = 11050

Gravatar Image5 - Ok, wow, that's way cooler than my page of code... and way over my head!!!

Post A Comment

:-D:-o:-p:-x:-(:-):-\:angry::cool::cry::emb::grin::huh::laugh::rolleyes:;-)