1. A method for storing data, the method comprising: a write process writing to a memory, wherein the physical characteristics of memory cells in the memory support different sets of data levels, and the write process takes into account the different sets of data levels when writing to the memory, the write process comprising: receiving a write message to be written to a block of memory cells in the memory; determining physical characteristics of the memory cells in the block; identifying virtual memories associated with the block of memory cells in response to the physical characteristics; performing for each of the virtual memories: generating a constraint vector that describes virtual cells in the virtual memory, the generating in response to the physical characteristics of the memory cells, to previously generated constraint vectors, and to previously generated virtual write vectors; and calculating a virtual write vector in response to a codebook, the constraint vector and the write message; combining the virtual write vectors into a write word; and outputting the write word to the block of memory cells.