draftply Download

Road Trip Planner

← All samples

road-trip.dplyEditor
1---
2app_version: 0.7.0
3precision: 2
4form_title: Road trip planner
5form_description: Distance, average speed and departure time in — see the driving time with a rest after every stint, when you arrive and what the fuel costs, with miles and gallons for anyone reading along abroad.
6form_inputs: Distance|distance{km}, Average speed|speed{km/h}, Departure|depart, Rest per stop|rest{min}, Consumption|consumption{L/100km}, Fuel price|fuel_price{€/L}
7form_outputs: Driving time|driving, Stops|stops, On the road|total, Arrival|arrival, Fuel needed|fuel, Fuel cost|fuel_cost, Distance in miles|miles
8---
9# Road trip planner
10// Durations are typed the way draftply shows them (2 h 30 min), and `in`
11// converts a result right in the line: `distance in mi`.
12// This notebook also has a FORM (Pro): Form → Form view for an input mask.
13
14# The trip
15distance = 640 km
16speed = 95 km/h // average, traffic included
17depart = 7:30
18
19# Time
20driving = distance / speed
21stint = 2 h 30 min // longest stretch at the wheel
22rest = 20 min // per stop
23stops = max(ceil(driving / stint) - 1, 0)
24total = driving + stops * rest
25arrival = depart + total
26
27# Fuel
28consumption = 6.5 L/100km
29fuel = distance * consumption
30fuel_price = 1.79 €/L
31fuel_cost = fuel * fuel_price
32
33# For friends abroad
34miles = distance in mi
35fuel in gal
36speed in mi/h
37