Weekly Mileage Planner

running
greedy algorithms
Author

Oliver Chang

Published

December 11, 2025

How does this work?

The mileage planner uses the Largest Remainder Method to efficiently manage and prioritize daily mileage allocations. It starts by calculating the base mileage for each day, then applies adjustments based on the selected day types (Easy, Workout) and distribution settings. To ensure integer mileages, it rounds down the calculated values and distributes the remaining “remainder” miles to the days with the largest fractional parts, ensuring the total weekly mileage is exactly met while maintaining the intended distribution.

However, we have to account for the long run day, which is set to a fixed percentage of the total weekly mileage. Thus, long run day mileage is calculated first, and the remaining mileage is distributed among the other days using the Largest Remainder Method. Let’s do an example:

  1. Set Weekly Mileage: Suppose the total weekly mileage is set to 32 miles and we have no workouts.
  2. Calculate Long Run Mileage: If the long run is set to 25% of the total, then the long run mileage is 0.25 * 32 = 8 miles.
  3. Distribute Remaining Mileage: The remaining mileage is 32 - 8 = 24 miles, which needs to be distributed over the other 5 days.
  4. Base Mileage Calculation: The base mileage for each of the 5 days is 24 / 5 = 4.8 miles.
  5. Apply Day Type Adjustments: If we have 4.8 miles per day we must take the floor of that (4 miles) and allocate the remaining 0.8 miles to the days with the largest fractional parts.
  6. Final Allocation: The final allocation would be:
    • Long Run: 8 miles
    • Day 1: 5 miles (4 + 1 from remainder)
    • Day 2: 5 miles (4 + 1 from remainder)
    • Day 3: 5 miles (4 + 1 from remainder)
    • Day 4: 5 miles (4 + 1 from remainder)
    • Day 5: 4 miles (4 + 0 from remainder)
  7. The Final Schedule:
    • Sunday Long Run: 8 miles
    • Saturday: 0 miles
    • Friday: 4 miles
    • Thursday: 5 miles
    • Wednesday: 5 miles
    • Tuesday: 5 miles
    • Monday: 5 miles