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

My algorithm for playing songs indefinitely in a random order:

1. let S = set of songs to be played

2. let N = number of songs

3. repeat until bored:

3.1. let R = set of last [N / 2] songs we played

3.2. pick a song at random from S \ R; play it

You may want to tweak step 3.2 to give higher probabilities of picking songs that haven't been played for longer.



Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

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

Search: