From the course: Level Up: C

Unlock this course with a free trial

Join today to access over 25,600 courses taught by industry experts.

Shuffling a playlist

Shuffling a playlist - C Tutorial

From the course: Level Up: C

Shuffling a playlist

(techno gaming music) - [Instructor] Shuffling a playlist is about more than just randomizing the order of songs, which can lead to unwanted duplication and repetition. For example, this code outputs 20 popular song titles in a random order. An integer array frequency tallies the number of times each song plays. So when the code is run, you see the distribution of songs is uneven. Some songs are playing back to back or over and over again. This is not a good shuffle. Your challenge is to randomly shuffle the playlist. I'll provide code for the shuffle, but you make the shuffle truly random. Your challenge is to improve the code in the challenge exercise file. Add statements that ensure the same song doesn't repeat until at least 15 other different songs have played. Keep the list random, not based on any pattern other than the 15-song no repeat rule. The result is more of a true shuffle than just randomly picking…

Contents