jperm algorithm explained in a tutorial