In accordance with one or more embodiments data may be encoded into a code
word that meets run length constraints and has a reduced running digital
sum by encoding (N-y)-1 data bits and y flag bits into m first n-bit
patterns that form a first N-bit code word, producing a second N-bit code
word by encoding the (N-y)-1 data bits and the y flag bits into m second
n-bit patterns in which corresponding first and second n-bit patterns
combine to meet a first predetermined running digital sum threshold, and
selecting the code word that satisfies selection criteria. The selection
criteria may, for example, be the word with the fewest transitions, the
word with the smallest running digital sum, and so forth.