Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The problem is separating tracks in the same group. If the globally sorted reference list of N songs has M consecutive entries that we want to spread evenly, they should be "shuffled" at increments of floor(N/M) or 1+floor(N/M): easy to guarantee with tortured recursive constructions like the one that opens the article, less obvious with a hash function that is affected by floating point approximations.

An integer formula that is more obvious to work: starting from any number between the maximum group size and (if larger) N/phi, pick an increment D as the next larger or smaller integer that has no common factors with N (to ensure full period) and map index K to index (S+K*D)%N.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: