hw9 greedy algorithm