vehicle(1) vehicle(2) function(vehicletype) { if (vehicletype === "bike") { return randRange(5, 15); } else if (vehicletype ==="horse") { return randRange(3, 30); } else if (vehicletype ==="train") { return randRange(30, 70); } else { return randRange(10, 65); } } REASONABLESPEED(VEHC1) REASONABLESPEED(VEHC2) SPEED1 < SPEED2 ? randRange(SPEED1 + 1, SPEED2 - 1) : randRange(SPEED2 + 1, SPEED1 - 1) randRange(1, 9) AVG * TIME (SPEED1 * SPEED2 * TIME - DIST * SPEED2) / (SPEED1 - SPEED2) DIST - DIST2

person(1) traveled by VEHC1 at an average speed of SPEED1 miles per hour.

Then, he(1) traveled by VEHC2 at an average speed of SPEED2 miles per hour.

In total, he(1) traveled DIST miles for plural(TIME, "hour").

How many miles did person(1) travel by VEHC1? (Round to the nearest mile.)

round(DIST1) miles

d_vehicleVar(1) = round(DIST1) miles

How many miles did person(1) travel by vehicle(2)? (Round to the nearest mile.)

round(DIST2) miles

d_vehicleVar(2) = round(DIST2) miles

How many minutes did person(1) travel by vehicle(1)? (Round to the nearest minute.)

round(DIST1 / SPEED1 * 60) minutes

t_vehicleVar(1) = round(DIST1 / SPEED1 * 60) minutes

How many minutes did person(1) travel by vehicle(2)? (Round to the nearest minute.)

round(DIST2 / SPEED2 * 60) minutes

t_vehicleVar(2) = round(DIST2 / SPEED2 * 60) minutes

Remember that d = r * t, or written another way, t = d / r.

d_vehicleVar(1) = distance that person(1) traveled by vehicle(1)

d_vehicleVar(2) = distance that person(1) traveled by vehicle(2)

Total distance: d_vehicleVar(1) + d_vehicleVar(2) = DIST

Total time: t_vehicleVar(1) + t_vehicleVar(2) = TIME

t_vehicleVar(1) = (d_vehicleVar(1) / SPEED1) and t_vehicleVar(2) = (d_vehicleVar(2) / SPEED2)

Substitute the blue equations for: (d_vehicleVar(1) / SPEED1) + (d_vehicleVar(2) / SPEED2) = TIME

Multiply the above equation by -1 * SPEED1: -d_vehicleVar(1) - (SPEED1 / SPEED2) * d_vehicleVar(2) = -SPEED1 * TIME

Add the two orange equations for: (SPEED2 - SPEED1 / SPEED2) * d_vehicleVar(2) = DIST - (SPEED1 * TIME)

Calculating all variables (and then rounding to the nearest integer):
d_vehicleVar(2) = roundTo( 4 , DIST2 ) (round(DIST2)) miles
d_vehicleVar(1) = roundTo( 4 , DIST1 ) (round(DIST1)) miles
t_vehicleVar(1) = roundTo( 4 , DIST1 / SPEED1 * 60 ) (round(DIST1 / SPEED1 * 60)) minutes
t_vehicleVar(2) = roundTo( 4 , DIST2 / SPEED2 * 60 ) (round(DIST2 / SPEED2 * 60)) minutes