Shuffle no consecutive repeats

I have a presentation test of recovery that I work on. The data begin by repeating a source like this (dynamically generated) material:

var thePrompts:Array = [1,1,1,2,2,2,3,3,3,4,4,4,4];

Can I mix data using this function:

function shuffle(a:Array):Array {}

a = a.Slice (0);

for (var i: int =. Length-1; i > = 0; i--) {}

var p:int=Math.floor(Math.random()*(1+i));

var t: * = a [i];

a [i] = a [p];

a [p] = t;

}

return a;

}

However, it's random and I could end up with consecutive as repetitions:

3,4,3,1,1,2,4,2,4,2,1,3,4

The most repeated comments. And of course, there could be a lot of repetition. One approach to brutal force to check everything and if she repeats shuffle, it again seems to work very well. But it seems that it could take an arbitrary number of attempts to achieve.

Does anyone know a smart algorithm to shuffle, but avoid consecutive repetitions?

Or the intelligent algorithms to work through with rehearsals and change them to no rehearsal?

If they all repeated a number of times and you have all the possible random rankings without consecutive repetitions, you can use:

var a: Array = [1,2,3,4];

var shuffledA:Array = shuffleSpecialF (a, 13);

function shuffleSpecialF(a:Array,n:int):Array {}

Shuffle (a);

var rA:Array=a.slice();

for (var i: int = 0; i

Shuffle (a);

{while (RA [RA. (Length-1]==a[0])}

Shuffle (a);

}

rA = rA.concat (a);

}

return of rA;

}

function shuffle(a:Array) {}

var p:int;

var t: *;

var ivar:int;

for (ivar =. Length-1; Ivar > = 0; Ivar-) {}

p = Math.Floor ((Ivar+1) * Math.Random ());

t = a [ivar];

a [ivar] = a [p];

a [p] = t;

}

}

Tags: Adobe Animate

Similar Questions

  • want to use regexp_replace in pl/sql to replace a string containing repeat them consecutive to a words

    Hi Experts,

    I want to use regexp_replace in pl/sql to convert a string containing consecutive repeat words have only one.

    for example: "is my name and and I was waiting for waiting for what it" should be replaced by "is my name and I was waiting for it."

    Thanks in advance

    Gordon

    A slight change '(\w+\S\W)\1+' )

    Concerning

    Etbin

  • Questions about fetures

    I have 2 questions, which could not meet.

    1. If I have the player Shuffle a song repeat at all before he went through all the songs in the library?  That is to say. If I have 1500 songs on the player, song #5 repeated at all before playing other songs of 1499 first.

    2 - the player will lose my place if rebooted or pluged?  That is to say. If I played 50 songs and restarting the player or is connected to a computer to charge, it will then leave my music again when played?

    Miikerman wrote:

    Yep, he again the shuffle, as far as I know (but I am not absolutely certain about it - maybe someone can experiment a bit and post it here).  A possibility -I wonder if you could create a playlist of all your songs and play this.

    Of course he could, but it won't have to avoid having to repeat the playlist after plugging in the computer. The problem is any time anything on the computer reads the files on the drive, if it be A / V software or other, which triggers an update of the database to the device.

    But rather than consider a "deal-breaker" and throw the baby out with the bath water, imhotep could also use the Rockbox firmware and do not have to suffer the way Sandisk firmware is written to work. In fact, he would not see a database refresh at all; It does in the background.

    Rockbox shuffle algorithm is supposed to be better though. More random and repeating all the songs until all have wagered. I don't know this 100%, but it's gossip.

  • iPod shuffle repeating same song

    iPod shuffle suddenly continues to repeat same song - can manually switch to the next track in a playlist, but cannot see how to activate this repetition off the shuffle?  I have a lot of songs in all the selections, I do not see a feature "a song" on the ipod shuffle, or I see a "repeat" function  Thank you

    It's an iPod shuffle, the little clip - one player with no screen?  You're right that an iPod shuffle not repeat current song setting.  iPod nano is...

  • option request to turn off the repeat & shuffle iPod

    I listen to audio books and love the option to stop at random and shuffle repeat settings. Or simply to lock the screen so it doesn't push the buttons randomly when I put the iPod in my pocket.

    Make a suggestion to Apple here:

    https://www.Apple.com/feedback/iPodTouch.html

  • Shuffle repeat

    I listen to my Clip Zip so I am at work, I got about 7 hours per day.  I Shuffle and including about 31 GB of music on it.  During the day, it's great because it does not repeat itself.  However, it seems that the Shuffled list starts at the same place every morning because I heard the same songs every day.  Is this a problem with my camera, or it's just the way the software is set up?

    just the way the software works. others have complained about shuffel as well, but he never changed.

  • "shuffle" and "repeat" in Windows Media Player

    If I select "shuffle" and "repeat" in Windows Media Player, it will play all the songs on my playlist once and then start over again?  This selection process start again if I exit the program, or it will pick up right where I left off?

    If you restart the program, the sequence is not known.

    If you turn on both, then yes it will go through everything and then continue.

  • You can erase the songs on your iPod shuffle and repeat?

    How do clear you the air out of an iPod Shuffle?

    Synchronize with iTunes, I guess.

  • Windows media player shuffle function does not work repeat the songs for two lanes

    I run windows 7 and Media player as my player used by default since I use a computer a decade ago, I find it does everything what I want (in general), however, recently, when I open him and invariably put to play a playlist, if it's the shuffle, it seems to alternate between two songs, I then go manually click on another track that , for some reason, seems to sort it out. Any ideas please? Martin.

    <p class="help"> <p class="reply">Hi Martin,</p> <p class="reply">You may need to rebuild the database from the Windows Media Player library.<br>Here's how:<br>a. exit Windows Media Player.<br>b. Click Start, run, type <strong>%LOCALAPPDATA%\Microsoft\Media Player</strong>and then click <strong>OK</strong>.<br>c. Select all files in the folder, and then click <strong>delete</strong> on the <strong>file</strong> menu.<br>Note: You don't have to remove the folders that are in this folder.<br>d. restart Windows Media Player.</p> <p class="reply">For further troubleshooting, see section to run the troubleshooting utility that resets the settings:</p> <p class="reply"><a href="http://windows.microsoft.com/en-IN/windows7/Open-the-Windows-Media-Player-Settings-troubleshooter" rel="external nofollow noreferrer">http://Windows.Microsoft.com/en-in/Windows7/open-the-Windows-Media-Player-settings-Troubleshooter</a></p> <p class="reply">Please let us know the results.</p>

  • Repeat AND shuffle

    Hello

    I need to work on the following...

    a = [[1,2,3,4], [5,6,7,8], [9,10,11,12], [13,14,15,16]]

    I need to choose at random two 2 lists a - no

    a = [[9,10,11,12], [1,2,3,4], [13,14,15,16], [5,6,7,8]], but

    b = [[1,2,3,4], [9,10,11,12]].

    What is the code for this?

    Thank you

    Thank you very much, Mr President!

    Exactly what I needed.

    I'll order a few books Director at amazon to spruce up my knowledge of the jargon...

    If this forum is appropriate - is there one that you would recommend?

    Thank you

  • audio playlist does not play consecutively

    I need to play music in a playlist consecutively, but for some reason, it jumps around. Fix programming there is?

    If you use WMP, you can disable shuffle by clicking on the button shuffle below.

    http://RES1.Windows.Microsoft.com/resbox/en/Windows%20Vista/main/df4ddec2-C192-46DD-8715-58fab97678be_14.PNG

    http://Windows.Microsoft.com/en-in/Windows-Vista/shuffle-and-repeat-items-in-Windows-Media-Player

  • How do you turn off shuffle on iOS10

    Since the update of iOS10.02 it is not a power to shuffle on and off or more of continuous play.  Once the shuffle is turned on it does not turn off even after that you reset the phone.  Does anyone know how to turn off or how to activate the continuous game?

    You can scroll down more than the song played screen showing. Theres a button to shuffle and repeat.

  • My iPod Shuffle 2nd Gen the same song just rehearsals

    I have an Ipod 2nd generation shuffle, and he will never play the song I put on, he would usually play about 6 of the continuously, despite having lots of songs on this subject. I recently restored to factory settings and got 64 songs on it, but he will play only one of them, which she repeats,

    The shuffle uses flash storage.  Flash storage ends by wears.  Thus, the cause may be a hardware problem on your shuffle, especially since a 2nd gen shuffle is about 10 years at this point.

    One thing you can try is to reformat the shuffle outside iTunes store.  This must be done in a particular way.  Are you using a Mac or a Windows PC?

  • iTunes 12.5 randomly adding to the next place; Shuffle off

    First of all, I want to mention that I am a developer of software (specifically for the iOS and OS X platforms), so I'm no stranger to the resolution of the problems. However, I've looked everywhere on the internet for people with a similar problem and found nothing!

    The question

    To play any song, whether it's straight out of an album in my recently added or one through research, my iTunes automatically adds songs randomly my library to the next place. So even if I decide to play the 4th song in an album, instead of playing the song 5 after that, he'll play another song randomly my library. Before ask you, shuffle is and has always been, disabled. I do not use the shuffle. It's one of the reasons as to why this is becoming quite annoying.

    Steps to reproduce

    Something to note that this happens only occasionally. Sometimes my library will play things very well, and then randomly, the bug will be add to my next place and ruin everything. The bug happens usually when I play on a new album. I use AirPlay occasionally as well, but I do not have all memory of if everything changes when enabled / disable. Curiously, he can't always launch. It be peut, but not always.

    As an estimate of the frequency approximate, if I'm playing music off my library for 5 hours of the day, it will happen 3 - 4 times.

    1. Open iTunes (make sure shuffle is off)
    2. Start playing a song from anywhere, be it of an album or single
    3. iTunes will eventually add songs to my next place at random

    Temporary workaround

    Even once to the top following was deleted, and I try to play a new song, iTunes will be once more, to add to the next place. It's that when I clear the next room, turn shuffle on and then turn off shuffle again, it stops. Sometimes the out-turned on will not work, and I have to repeat 2 or 3 times until it finally stopped.

    This question and discovered the following:

    It depends on where you click to start the track. If you click directly with simple click the small arrow that appears when moving the mouse on the title you want to play first, he will play songs randomly thereafter.

    If you double-click the title itself (not the small arrow), then it will play not random.

    It's not intuitive user experience.

  • How to repeat a song on iTunes?

    How to repeat a song on iTunes?

    Two ways...

    Go to the Shuffle icon on the right side of the title of the song and click on it and a 1 will appear later. The other method is to go to the top in the toolbar and select "commands > repeat > a".

Maybe you are looking for