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 - 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
-
-
-
Generating ordinal values2m 34s
-
(Locked)
Centering text2m 22s
-
(Locked)
Making change2m 17s
-
(Locked)
Simulating the hailstone sequence2m 36s
-
(Locked)
Performing a perfect shuffle2m 23s
-
(Locked)
Chopping up a string2m 49s
-
(Locked)
Determining a leap year2m 35s
-
(Locked)
Shuffling a playlist2m 32s
-
(Locked)
Letting the king wander2m 20s
-
(Locked)
Rotating a matrix2m 31s
-
(Locked)
Calculating next Monday's date2m 32s
-
(Locked)
Adding commas to numeric output2m 25s
-
(Locked)
Scoring a frame in bowling2m 20s
-
(Locked)
Calculating the golden ratio2m 50s
-
(Locked)
Wrapping text2m 9s
-