if ive a 1000 songs,using shuffle whats the probability, on average, how many tracks will be played before a previous song plays again.
tricky probability Q, getting a few different answers, with some variation of accuracy!!
thanks
pjh-10 0 Light Poster
Recommended Answers
Jump to Post— pheininger 5you want to find out how many songs play before a previous played song comes up again, thats the task. the answer is less than 50 songs, that much i know. so want to do the shuffle, and feed the random number you get back into a loop, which breaks …
Jump to Post— pheininger 5how do you get the random number generated,
- using rand() function
fed into a loop
- use the loop to generate the songs in sequence
- keeping a record of the songs played in an array or vector
(so that it repeats until, the fed number is repeated)
- …
Jump to Post— Lerner 582Here's another "experimental" approach, in pseuocode:
declare an array of type bool, size 1000---say boolArray.
declare an int called numSelectiions
1) set boolArray to all false
2) set numSelections to 0
3) pick a random number, i, between 0 and 999
4) increment numSelections by one
5) if boolArray …
Jump to Post— Lerner 582Here's a pencil and paper example of my previous suggestion using a scaled down version of the process to get your hands and head around the concepts without feeling overwhelmed. See if it makes sense to you. If so change it to pseudo code and then to code.
Jump to Post— pheininger 5from the last code i posted, where would i go from there? thanks
From my point of view, either 1) if you are going to keep to a "shuffle" design that is not required, fix the while expression (I think (my C++ is limited also) the value of (cin >> …
All 77 Replies
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
pjh-10 0 Light Poster
Moschops 683 Practically a Master Poster Featured Poster
histrungalot 32 Junior Poster
pjh-10 0 Light Poster
Moschops 683 Practically a Master Poster Featured Poster
pjh-10 0 Light Poster
Moschops 683 Practically a Master Poster Featured Poster
pjh-10 0 Light Poster
Moschops 683 Practically a Master Poster Featured Poster
pjh-10 0 Light Poster
Moschops 683 Practically a Master Poster Featured Poster
Moschops 683 Practically a Master Poster Featured Poster
histrungalot 32 Junior Poster
Moschops 683 Practically a Master Poster Featured Poster
pjh-10 0 Light Poster
Nathaniel10 34 Junior Poster
Moschops 683 Practically a Master Poster Featured Poster
pjh-10 0 Light Poster
Nathaniel10 34 Junior Poster
Moschops 683 Practically a Master Poster Featured Poster
histrungalot 32 Junior Poster
Moschops 683 Practically a Master Poster Featured Poster
pjh-10 0 Light Poster
Moschops 683 Practically a Master Poster Featured Poster
Nathaniel10 34 Junior Poster
histrungalot 32 Junior Poster
Moschops 683 Practically a Master Poster Featured Poster
nezachem 616 Practically a Posting Shark
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.