select greedy code