Sprint Interval Calculator

Calculate HIIT sprint interval workouts with Tabata, Sprint 8, and custom protocols.

SprintIntervalCalculator.presets

Часто задаваемые вопросы

Реализация кода

import math

def calculate_hiit_session(protocol: str, body_weight_kg: float) -> dict:
    """Calculate HIIT sprint interval session details."""
    protocols = {
        "tabata":   {"sprint": 20, "rest": 10, "sets": 8, "rounds": 1, "rest_between": 60},
        "30-60":    {"sprint": 30, "rest": 60, "sets": 8, "rounds": 1, "rest_between": 0},
        "40-20":    {"sprint": 40, "rest": 20, "sets": 8, "rounds": 1, "rest_between": 60},
        "sprint8":  {"sprint": 30, "rest": 90, "sets": 8, "rounds": 1, "rest_between": 0},
    }
    p = protocols.get(protocol, protocols["tabata"])

    # MET-based calorie estimation
    MET_SPRINT = 14.0   # sprint running
    MET_WALK = 3.5      # recovery walking

    sprint_time_min = (p["sprint"] * p["sets"]) / 60
    rest_time_min = (p["rest"] * p["sets"] + p["rest_between"]) / 60

    cal_sprint = MET_SPRINT * body_weight_kg * sprint_time_min / 60
    cal_rest = MET_WALK * body_weight_kg * rest_time_min / 60
    total_cal = cal_sprint + cal_rest

    total_time = p["sprint"] * p["sets"] + p["rest"] * p["sets"] + p["rest_between"]

    return {
        "protocol": protocol,
        "sets": p["sets"],
        "sprint_sec": p["sprint"],
        "rest_sec": p["rest"],
        "total_time_sec": total_time,
        "calories_burned": round(total_cal, 1),
    }

result = calculate_hiit_session("tabata", 70)
print(f"Protocol: {result['protocol']}")
print(f"Sets: {result['sets']} x {result['sprint_sec']}s sprint / {result['rest_sec']}s rest")
print(f"Total time: {result['total_time_sec']}s ({result['total_time_sec']//60}min {result['total_time_sec']%60}s)")
print(f"Estimated calories: {result['calories_burned']} kcal")

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.