# Pace Calculator

Enter any distance and time and the pace will be caluculated for you.

The form tries to be a little smart about deducing units from
abbreviations in the distance field. For instance, you can say
“3.2m” and it will assume 3.2 *miles*, even though
“m” is the technical abbreviation for *meters*. The
assumption is that you're not interested in calculating pace for a 3.2
meter sprint. The heuristic is simple: if the number before the
“m” is less than 100, assume miles. Otherwise, meters. If
you want to avoid ambiguity - or if you're running the 50m dash or an
ultra-marathon - use “M” for miles and “meters”
for meters.

For the time fields you can use “m”, for minutes “s” for seconds, and “h” for hours. Or, you can use minute and second marks (e.g. 8'30").

For a simple tool, there is enough meat in this to afford some good thinking about design and implementation. For instance, it's easy to see that given any two of distance, time, and pace, the obvious next step is to calculate the third. No need for a button press. However, it's less obvious what the best behavior should be when all three fields are filled but one of them has just been changed by the user. Update the field that was updated second to last? Assume the distance is a given and update whichever of the other two was not just changed by the user?

And race paces are one of the few places where mixed units are fairly common. A 10K runner may very well want to know their pace in minutes per mile and a Marathon runner may very well want to know their pace in minutes per kilometer. How can this tool best serve the user without overwhelming them with complexity and while not sacrificing too much flexibility with assumptions.

Some distance numbers lend themselves pretty naturally to only one
unit interpretation. If you see 10,000 for a distance, you can assume it's
*meters* and nothing else. 26.2 is probably miles (although the
Marathon is technically 26.2187 miles, and that fractional part tends
to make a second per mile difference in pace). 5 and 10 are ambiguous
but are never *meters* in any case.

Perhaps you could say that distance magnitudes below 100 are never
meters while magnitudes above 1000 are *always* meters. It only
helps a little but it does help.