Flash memory is a non-volatile computer storage device which consists of blocks of cells. While increasing the voltage level of a single cell is fast and simple, reducing the level of a cell requires the erasing of the entire block containing the cell. Since block erasures are costly, traditional flash coding schemes have been developed to maximize the number of writes before a block erasure is needed. A novel coding scheme based on error-correcting codes allows the cell levels to increase as evenly as possibly and as a result, increases the number of writes before a block erasure. The scheme is also capable of combating noise in flash memories in order to enhance data reliability.