Here is the greedy algorithm from Adam in it's latest form.