calc code from length