SD 212 Spring 2023 / Homeworks


This is the archived website of SD 212 from the Spring 2023 semester. Feel free to browse around; you may also find more recent offerings at my teaching page.

hw03: Marathon chip timing

  • Due before the beginning of class on Friday, January 13

The data

Some of the world’s most famous historical figures (as calculated by Wikipedia page views) have run a chip-timed marathon race. The course was out-and-back, so each runner went over the timing mat twice, once at the beginning when they started and again at the end when they finished.

times.csv is a file containing marathon chip times. (Follow that link to have a look at the file, and there is a link at the top of that page which will allow you to download it.)

Each name appears twice in this file for the two times they crossed the mat; their marathon time will be the difference between these two time values.

Your task

Write a program marathon.py which reads in the data from a file called times.csv and prints out the name of the marathon winner, i.e., the person who had the shortest time from start to finish.

In the sample times.csv file provided, the winner is ChristianBale with an impressive time of 02:09:00. Here’s how it should look if you run it:

roche@ubuntu$ python3 marathon.py
ChristianBale
We may also test your code with different input files, but they will always be called `times.csv` (so you can just hard-code that filename into your program).

Submit command

To submit files for this homework, run one of these commands:

submit -c=sd212 -p=hw03 marathon.py
club -csd212 -phw03 marathon.py