zkbro

💻 Friday Evening Coding

2025-10-03 22:29

I gave in. My head just can't handle how to convert total time in seconds and total distance in meters to an average pace in minutes per kilometer. My logic is:

But of course there's remainders and things that muck it all up and causes my head to mush when I try and write it in python. So (is this the part where AI makes me stupider?), I GPT'd it and it gave me:

pace_sec_per_km = moving_time / (distance / 1000)

minutes = int(pace_sec_per_km // 60)
seconds = int(pace_sec_per_km % 60)

pace = f"{minutes}:{seconds:02d} /km"

print("Pace:", pace)

The pieces I didn't know about (but do now, because I asked some follow-up questions):

*Edit - I can drop the d altogether because I've already declared seconds as an integer with int.

I find it a nightmare to find those little tidbits through web searching, so GPT it was. I've thoroughly enjoyed coding this week without AI, but I'm also happy it exists for little things like this.

Anyway, I'm getting pretty close now to a script that publishes all my activities to my site like a Strava feed with maps and all.