A wide class of problems in coding theory are dealt with using a greedy algorithm due to Stein and Lovasz [15, 20]. Some examples, including constructing covering codes, codes for conflict resolution, separating systems, source encoding with distortion, etc., are given a unified treatment.