Reconstructing affine codes from their memory traces