News for hackers. Stuff that matters.
Re:“A calculator app? Anyone could make that” by AlotOfReading on Sunday February 16, 2025 @02:23PM (#43070822)
One way to do it without retaining additional state would be to generate the initial shuffle for N > current song list. If the new songs' indices come up, they get played. You skip any indices that don't correspond to a valid song when it's time to play them.

This has some obvious downsides (e.g. an empty slot that was skipped when played and filled by a later insert won't be played), but it handles both insertion and deletions without replaying songs and you only need to store a single integer.

There are no comments on this comment yet.