Search Results

Search found 158 results on 7 pages for 'shuffle'.

Page 1/7 | 1 2 3 4 5 6 7  | Next Page >

  • iPod Shuffle (3G) - USB adapter cables

    - by bencnscp
    The iPod shuffle (3G) seems to have a proprietary connector that is different than the previous one for iPod shuffle (2G). I have tried the cable that comes with the 2G, and even a 3rd party charger, and their connectors are physically keyed so you cannot plug them in. Is anyone using a 3rd-party cable (besides the one Apple provided)?

    Read the article

  • after shuffle a list get array with jquery

    - by robertdd
    i want after i shuffle a list of images to get all the alt="" value in one array! but i get always the save value!why? $('ul').shuffle(); //this will shuffle the list var a = {}; $("ul img").each(function() { a[this.alt] = $(this).attr("alt"); }); $.operation(a, shuffle);

    Read the article

  • Maximal Length of List to Shuffle with Python random.shuffle?

    - by Henrik
    I have a list which I shuffle with the Python built in shuffle function (random.shuffle) However, the Python reference states: Note that for even rather small len(x), the total number of permutations of x is larger than the period of most random number generators; this implies that most permutations of a long sequence can never be generated. Now, I wonder what this "rather small len(x)" means. 100, 1000, 10000,... Can anybody clarify? Thanks!

    Read the article

  • How to shuffle pairs

    - by Jessy
    How to shuffle the elements in the pairs? The program below, generate all possible pairs and later shuffle the pairs. e.g. possible pairs before shuffle is ab,ac,ae,af..etc shuffled to ac,ae,af,ab...etc How to make it not only shuffled in pairs but within the elements in the pair itself? e.g. instead of ab, ac, how can I make ba, ac ? String[] pictureFile = {"a.jpg","b.jpg","c.jpg","d.jpg","e.jpg","f.jpg","g.jpg"}; List <String> pic1= Arrays.asList(pictureFile); ... ListGenerator pic2= new ListGenerator(pic1); ArrayList<ArrayList<Integer>> pic2= new ArrayList<ArrayList<Integer>>(); public class ListGenerator { public ListGenerator(List<String> pic1) { int size = pic1.size(); // create a list of all possible combinations for(int i = 0 ; i < size ; i++) { for(int j = (i+1) ; j < size ; j++) { ArrayList<Integer> temp = new ArrayList<Integer>(); temp.add(i); temp.add(j); pic2.add(temp); } } Collections.shuffle(pic2); } //This method return the shuffled list public ArrayList<ArrayList<Integer>> getList() { return pic2; } }

    Read the article

  • Javascript Number Random Shuffle

    - by stjowa
    Hi, I need a Javascript random number shuffler for my website. Seems simple, but I can not figure out how to do it. Can anyone help me out? I have the following array of numbers: 1 2 3 4 5 6 7 8 9 I would like to be able to have these numbers shuffled randomly. Like the following: 3 6 4 2 9 5 1 8 7 or 4 1 7 3 5 9 2 6 8 So, specifically, I would like a function that takes in an array of numbers (1 - n) and then returns that same array of numbers - shuffled randomly with different calls to the function. Maybe a noob function, but can't seem to figure it out. Thanks! NOTE: Thanks for the clarification on "Shuffle". Have found a lot more online about this with that term.

    Read the article

  • Number Random Shuffle

    - by stjowa
    Hi, I need a Javascript random number shuffler for my website. Seems simple, but I can not figure out how to do it. Can anyone help me out? I have the following array of numbers: 1 2 3 4 5 6 7 8 9 I would like to be able to have these numbers shuffled randomly. Like the following: 3 6 4 2 9 5 1 8 7 or 4 1 7 3 5 9 2 6 8 So, specifically, I would like a function that takes in an array of numbers (1 - n) and then returns that same array of numbers - shuffled randomly with different calls to the function. Maybe a noob function, but can't seem to figure it out. Thanks! NOTE: Thanks for the clarification on "Shuffle". Have found a lot more online about this with that term.

    Read the article

  • Most efficient way to randomly "sort" (Shuffle) a list of integers in C#

    - by Carl
    I need to randomly 'sort' a list of integers (0-1999) in the most efficient way possible. Any ideas? Currently, I am doing something like this: bool[] bIndexSet = new bool[iItemCount]; for (int iCurIndex = 0; iCurIndex < iItemCount; iCurIndex++) { int iSwapIndex = random.Next(iItemCount); if (!bIndexSet[iSwapIndex] && iSwapIndex != iCurIndex) { int iTemp = values[iSwapIndex]; values[iSwapIndex] = values[iCurIndex]; values[iCurIndex] = values[iSwapIndex]; bIndexSet[iCurIndex] = true; bIndexSet[iSwapIndex] = true; } }

    Read the article

  • Looking for a shuffle radio mp3 player

    - by ofir
    I'm looking for a shuffle radio MP3 player that I can embed in my site which: shows album and title and link to buy track and album in shop Like this one: http://phpfoxmods.net/clients/productsview.php?id=7 But this is integrated with MP3 community. MP3 broadcast should be secured, free or paid solution? Better integrated with shop or WP? Simple shop like this: http://idevspot.com/demos/idev-musicshop/index.php

    Read the article

  • Is there a media/music player program that has a "biased" shuffle?

    - by Joel Coehoorn
    I know in iTunes and a few other apps you can get playlists for just "highly rated" songs, but that's not quite what I want. I want to hear the lower-rated stuff, too. If I didn't like the song at some level it wouldn't be in my library in the first place, and so even a one-star song is worth the occasional listen. However, I do want to hear five-star songs a lot more often than one-star songs, even though I think I have a lot more one-star songs in my music library. So does anyone know of media player software of plugin (preferrable free) that has a shuffle mode that is biased towards songs that are rated higher, without completely excluding those that are rated lower? Right now I prefer windows media player, so a plugin for that would be ideal, but I'm not married to media player, either. Any music software that will do this would be worth some attention.

    Read the article

  • Second gen ipod shuffle not working with rhythmbox

    - by richzilla
    hi all, I'm trying to get a second gen ipod shuffle to work with Ubuntu 10.10. As far as i understand Rhythymbox should support this. When I plug the ipod in it shows up under the devices section of the menu, but after that I am unable to do anything with it. I can't see the songs that are already on it, I can't add new songs, I can't do anything. When i attempt to drag a song across, absolutely nothing happens. if i try the sync with library option, it shuts rhythymbox down completely. Any ideas would be greatly appreciated.

    Read the article

  • 15 Puzzle Shuffle Method Issues

    - by Codemiester
    I am making a 15 puzzle game in C# that allows the user to enter a custom row and column value up to a maximum of a 10 x 10 puzzle. Because of this I am having problems with the shuffle method. I want to make it so the puzzle is always solvable. By first creating a winning puzzle then shuffling the empty space. The problem is it is too inefficient to call every click event each time. I need a way to invoke the click event of a button adjacent to the empty space but not diagonal. I also use an invisible static button for the empty spot. The PuzzlePiece class inherits from Button. I am not too sure how to do this. I would appreciate any help. Thanks here is what I have: private void shuffleBoard() { //5 is just for test purposes for (int i = 0; i < 5; i++) { foreach (Control item in this.Controls) { if (item is PuzzlePiece) { ((PuzzlePiece)item).PerformClick(); } } } } void PuzzlePiece_Click(object sender, EventArgs e) { PuzzlePiece piece = (PuzzlePiece)sender; if (piece.Right == puzzleForm.emptyPiece.Left && piece.Top == puzzleForm.emptyPiece.Top) { movePiece(piece); } else if (piece.Left == puzzleForm.emptyPiece.Right && piece.Top == puzzleForm.emptyPiece.Top) { movePiece(piece); } else if (piece.Top == puzzleForm.emptyPiece.Bottom && piece.Left == puzzleForm.emptyPiece.Left) { movePiece(piece); } else if (piece.Bottom == puzzleForm.emptyPiece.Top && piece.Left == puzzleForm.emptyPiece.Left) { movePiece(piece); } }

    Read the article

  • How to shuffle pieces of large video files?

    - by Gabriël
    Hi Folks, For a party we want to show film-fragments using a projector. We have around 50 full-length movie avis and would like to shuffle them in shorter pieces. So every ca. 2-5 minutes another piece should begin. For example a sequence could be: Movie05-12m00s-14m30s, Movie08-55m50s-57m00s, Movie02-02m42s-06m40s, etc. So, random movies, at random positions within the movie of random lengths. What would be the kind of solution we're looking for? We were thinking 2 scenarios: Before doing this use some kind of tool to cut all avis in smaller pieces and put them on shuffle in a regular media player A sort of "VJ" program that can do this shuffle mixing realtime. Any suggestions for any of the above scenarios? Thanks!

    Read the article

  • Shuffle tiles position in the beginning of the game XNA Csharp

    - by GalneGunnar
    Im trying to create a puzzlegame where you move tiles to certain positions to make a whole image. I need help with randomizing the tiles startposition so that they don't create the whole image at the beginning. There is also something wrong with my offset, that's why it's set to (0,0). I know my code is not good, but Im just starting to learn :] Thanks in advance My Game1 class: { public class Game1 : Microsoft.Xna.Framework.Game { GraphicsDeviceManager graphics; SpriteBatch spriteBatch; Texture2D PictureTexture; Texture2D FrameTexture; // Offset för bildgraff Vector2 Offset = new Vector2(0,0); //skapar en array som ska hålla delar av den stora bilden Square[,] squareArray = new Square[4, 4]; // Random randomeraBilder = new Random(); //Width och Height för bilden int pictureHeight = 95; int pictureWidth = 144; Random randomera = new Random(); int index = 0; MouseState oldMouseState; int WindowHeight; int WindowWidth; public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; //scalar Window till 800x 600y graphics.PreferredBackBufferWidth = 800; graphics.PreferredBackBufferHeight = 600; graphics.ApplyChanges(); } protected override void Initialize() { IsMouseVisible = true; base.Initialize(); } protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); PictureTexture = Content.Load<Texture2D>(@"Images/bildgraff"); FrameTexture = Content.Load<Texture2D>(@"Images/framer"); //Laddar in varje liten bild av den stora bilden i en array for (int x = 0; x < 4; x++) { for (int y = 0; y < 4; y++) { Vector2 position = new Vector2(x * pictureWidth, y * pictureHeight); position = position + Offset; Rectangle square = new Rectangle(x * pictureWidth, y * pictureHeight, pictureWidth, pictureHeight); Square frame = new Square(position, PictureTexture, square, Offset, index); squareArray[x, y] = frame; index++; } } } protected override void UnloadContent() { } protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); MouseState ms = Mouse.GetState(); if (oldMouseState.LeftButton == ButtonState.Pressed && ms.LeftButton == ButtonState.Released) { // ta reda på vilken position vi har tryckt på int col = ms.X / pictureWidth; int row = ms.Y / pictureHeight; for (int x = 0; x < squareArray.GetLength(0); x++) { for (int y = 0; y < squareArray.GetLength(1); y++) { // kollar om rutan är tom och så att indexet inte går utanför för "col" och "row" if (squareArray[x, y].index == 0 && col >= 0 && row >= 0 && col <= 3 && row <= 3) { if (squareArray[x, y].index == 0 * col) { //kollar om rutan brevid mouseclick är tom if (col > 0 && squareArray[col - 1, row].index == 0 || row > 0 && squareArray[col, row - 1].index == 0 || col < 3 && squareArray[col + 1, row].index == 0 || row < 3 && squareArray[col, row + 1].index == 0) { Square sqaure = squareArray[col, row]; Square hal = squareArray[x, y]; squareArray[x, y] = sqaure; squareArray[col, row] = hal; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { Vector2 goalPosition = new Vector2(x * pictureWidth, y * pictureHeight); squareArray[x, y].Swap(goalPosition); } } } } } } } } //if (oldMouseState.RightButton == ButtonState.Pressed && ms.RightButton == ButtonState.Released) //{ // for (int x = 0; x < 4; x++) // { // for (int y = 0; y < 4; y++) // { // } // } //} oldMouseState = ms; base.Update(gameTime); } protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); WindowHeight = Window.ClientBounds.Height; WindowWidth = Window.ClientBounds.Width; Rectangle screenPosition = new Rectangle(0,0, WindowWidth, WindowHeight); spriteBatch.Begin(); spriteBatch.Draw(FrameTexture, screenPosition, Color.White); //Ritar ut alla brickorna förutom den som har index 0 for (int x = 0; x < 4; x++) { for (int y = 0; y < 4; y++) { if (squareArray[x, y].index != 0) { squareArray[x, y].Draw(spriteBatch); } } } spriteBatch.End(); base.Draw(gameTime); } } } My square class: class Square { public Vector2 position; public Texture2D grafTexture; public Rectangle square; public Vector2 offset; public int index; public Square(Vector2 position, Texture2D grafTexture, Rectangle square, Vector2 offset, int index) { this.position = position; this.grafTexture = grafTexture; this.square = square; this.offset = offset; this.index = index; } public void Draw(SpriteBatch spritebatch) { spritebatch.Draw(grafTexture, position, square, Color.White); } public void RandomPosition() { } public void Swap(Vector2 Goal ) { if (Goal.X > position.X) { position.X = position.X + 144; } else if (Goal.X < position.X) { position.X = position.X - 144; } else if (Goal.Y < position.Y) { position.Y = position.Y - 95; } else if (Goal.Y > position.Y) { position.Y = position.Y + 95; } } } }

    Read the article

  • Is Collections.shuffle suitable for a poker algorithm?

    - by Kovu
    Hi, there is a poker-system in java, that uses Collections.shuffle() on all available cards before the cards are dealt. So a collection of 52 cards 2-9, J, Q, K, A in 4 types. After that we Collections.shuffle(). The problem is, that it seems (until now we didn't have big statistic, it's possible that we only see a lot of statistic inferences), that the algorithm is VERY unclearly. So, is Collections.shuffle() okay for a poker algorithm?

    Read the article

  • How can I use the Fisher-Yates shuffle while ensuring my permutation is even?

    - by Mithrax
    I'm interested making an implementation of the 14-15 puzzle: I'm creating an array with the values 0 - 15 in increasing order: S = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } Now, what I want to do is shuffle them to create a new instance of the puzzle. However, I know that if I create a board with an "odd permutation" than it is unsolvable. Wikipedia says I need to create the puzzle with an even permutation. I believe this means that I simply have to do ensure I do an even number of swaps? How would I modify Fisher-Yates so I ensure I end up with an even permutation at the end? If I do a swap for every element in the array that would be 16 swaps which I believe would be an even permutation. However, do I need to be concerned about swapping with itself? Is there any other way to ensure I have a valid puzzle?

    Read the article

  • How can I ensure that when I shuffle my puzzle I still end up with an even permutation?

    - by Mithrax
    I'm interested making an implementation of the 14-15 puzzle: I'm creating an array with the values 0 - 15 in increasing order: S = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } Now, what I want to do is shuffle them to create a new instance of the puzzle. However, I know that if I create a board with an "odd permutation" than it is unsolvable. Wikipedia says I need to create the puzzle with an even permutation. I believe this means that I simply have to do ensure I do an even number of swaps? How would I modify Fisher-Yates so I ensure I end up with an even permutation at the end? If I do a swap for every element in the array that would be 16 swaps which I believe would be an even permutation. However, do I need to be concerned about swapping with itself? Is there any other way to ensure I have a valid puzzle?

    Read the article

  • Is it possible to shuffle a 2D matrix while preserving row AND column frequencies?

    - by j_random_hacker
    Suppose I have a 2D array like the following: GACTG AGATA TCCGA Each array element is taken from a small finite set (in my case, DNA nucleotides -- {A, C, G, T}). I would like to randomly shuffle this array somehow while preserving both row and column nucleotide frequencies. Is this possible? Can it be done efficiently? [EDIT]: By this I mean I want to produce a new matrix where each row has the same number of As, Cs, Gs and Ts as the corresponding row of the original matrix, and where each column has the same number of As, Cs, Gs and Ts as the corresponding column of the original matrix. Permuting the rows or columns of the original matrix will not achieve this in general. (E.g. for the example above, the top row has 2 Gs, and 1 each of A, C and T; if this row was swapped with row 2, the top row in the resulting matrix would have 3 As, 1 G and 1 T.) It's simple enough to preserve just column frequencies by shuffling a column at a time, and likewise for rows. But doing this will in general alter the frequencies of the other kind. My thoughts so far: If it's possible to pick 2 rows and 2 columns so that the 4 elements at the corners of this rectangle have the pattern XY YX for some pair of distinct elements X and Y, then replacing these 4 elements with YX XY will maintain both row and column frequencies. In the example at the top, this can be done for (at least) rows 1 and 2 and columns 2 and 5 (whose corners give the 2x2 matrix AG;GA), and for rows 1 and 3 and columns 1 and 4 (whose corners give GT;TG). Clearly this could be repeated a number of times to produce some level of randomisation. Generalising a bit, any "subrectangle" induced by a subset of rows and a subset of columns, in which the frequencies of all rows are the same and the frequencies of all columns are the same, can have both its rows and columns permuted to produce a valid complete rectangle. (Of these, only those subrectangles in which at least 1 element is changed are actually interesting.) Big questions: Are all valid complete matrices reachable by a series of such "subrectangle rearrangements"? I suspect the answer is yes. Are all valid subrectangle rearrangements decomposable into a series of 2x2 swaps? I suspect the answer is no, but I hope it's yes, since that would seem to make it easier to come up with an efficient algorithm. Can some or all of the valid rearrangements be computed efficiently? This question addresses a special case in which the set of possible elements is {0, 1}. The solutions people have come up with there are similar to what I have come up with myself, and are probably usable, but not ideal as they require an arbitrary amount of backtracking to work correctly. Also I'm concerned that only 2x2 swaps are considered. Finally, I would ideally like a solution that can be proven to select a matrix uniformly at random from the set of all matrices having identical row frequencies and column frequencies to the original. I know, I'm asking for a lot :)

    Read the article

  • php shuffle() returns one item

    - by mike
    Anyone have any idea why shuffle() would only return 1 item? when using: $array2 = shuffle($array1); with the following array($array1): Array ( [0] => 1 [1] => 5 [2] => 6 [3] => 7 [4] => 8 [5] => 10 [6] => 11 [7] => 12 [8] => 13 [9] => 14 ) The output of: print_r($array2); is simply: 1 Any idea as to why it would not only not shuffle the array, but knock off the remaining 9 items in the array? thanks!

    Read the article

  • novice needing help on shuffeling an array

    - by steffen Myklebust
    Please help a TOTAL beginner.! I found this post: http://stackoverflow.com/questions/56648/whats-the-best-way-to-shuffle-an-nsmutablearray And as i try to deploy this in my own code, I cant get it working... :-( Can anyone help me to resolve this code? To me it looks like the shuffle function is not called..? here is my code: // // shuffle2ViewController.h // shuffle2 #import @interface shuffle2ViewController : UIViewController { NSMutableArray *puzzles; int *randomSort; } - (void)shuffle; @end //============================= // shuffle2ViewController.m ´#import "shuffle2ViewController.h" @implementation shuffle2ViewController (void)viewDidLoad { [super viewDidLoad]; NSMutableArray *puzzles = [NSMutableArray arrayWithObjects:@"1",@"2",@"3", @"4",@"5",@"6",@"7",@"8",@"9", @"10",@"11",@"12", nil]; // Call the shuffle function [self shuffle]; // print to log int i; NSLog(@"NEW OLD"); NSLog(@"================="); for (i = 0; i < 12; ++i) NSLog(@" %2i %@", i + 1, [puzzles objectAtIndex:i]); } int randomSort(id obj1, id obj2, void *context ) { // returns random number -1 0 1 return (random()%3 - 1); } (void)shuffle { // call custom sort function [puzzles sortUsingFunction:randomSort context:nil]; } Giving this result: NEW OLD ================= 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12

    Read the article

  • How can I shuffle an NSArray?

    - by Mr. McPepperNuts
    All examples I find on shuffling arrays are for NSMutableArrays. Copying an NSArray to an NSMutable array, shuffling, then copying back always crashes the application. Is it even possible to shuffle an NSArray? Anything in objective-c similar to Collections.shuffle() (Java)?

    Read the article

1 2 3 4 5 6 7  | Next Page >