I haven't posted a puzzle in a while so here is a new one.
Category None
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?
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
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???
Posted by Adeleida At 02:43:24 AM On 03/18/2007 | - Website - |
Posted by Carl At 10:49:21 AM On 03/19/2007 | - Website - |
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
Posted by Adeleida At 01:52:49 PM On 03/19/2007 | - Website - |
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
Posted by Glen At 03:45:32 PM On 03/19/2007 | - Website - |
Posted by Adeleida At 04:14:55 PM On 03/19/2007 | - Website - |