Algorithms Extra Credit Homework in Python