greedy problem 6