Questions tagged [shuffle]

Shuffling is the act of randomizing the order of the elements in a collection.

Filter by
Sorted by
Tagged with
3
votes
2answers
81 views

A basic trivia app

The app grabs 10 questions from an API, displays them one by one with 4 multiple choice answers. These answers are clickable buttons that alert to whether the answer is correct or not. Finally the ...
3
votes
1answer
3k views

Shuffling a JSON array in Java

Since I did not get a satisfactory answer here (and I really needed to get it going on this weekend), I decided to implement my own Fisher–Yates shuffle, porting the code I found in other SO posts. I ...
3
votes
1answer
350 views

Secret Santa - Pick Pairs

Interested to hear your thoughts on this Secret Santa pairs picker. It's pretty standard but I'll explain the rules all the same: All names go into a hat Each person picks a name from the hat and ...
2
votes
3answers
4k views

Two ways to randomly shuffle cards

Here are two implementations I wrote to randomly shuffle cards. The first method (shuffle) selects a random card, then swaps it to the front. The second method (<...
2
votes
2answers
116 views

Shuffle array elements by rearranging the key value associations

PHP's shuffle() function destroys the array keys, so I decided to write a shuffle function that doesn't do that and instead rearranges key-value associations. As I ...
2
votes
1answer
2k views

csvshuf: a tool to shuffle CSV columns written in Python

Edit: After reading Gareth's answer I have pushed an updated version of the code to github. I needed to shuffle cells from specific columns in several CSV files. One of the requirements was to be ...
2
votes
1answer
140 views

Game to shuffle and guess a word

I'm new to C++ and while learning, I wrote a simple program that asks for a word, shuffle sthe characters and then asks another person to find the original word, given the shuffled letters. I would ...
2
votes
2answers
4k views

Fisher–Yates shuffle in C#

Is this a proper C# implementation of the Fisher–Yates shuffle? ...
2
votes
2answers
78 views

Return Set<Integer> with random unique Integer numbers between min and max range

I need set of random unique Integer numbers for my unit test. I implemented this method, however I'm not sure if this is best way to implement this. ...
2
votes
2answers
52 views

Continuous Shuffler with “linked loop”

As an academic exercise, I decided to implement a continuous shuffler, as seen on casino blackjack tables. It operates by storing a "linked loop" (a linked list with the last element linked to the ...
2
votes
1answer
61 views

Comparing two shuffling methods

I'm trying to randomly shuffle an collection of integers within a List and I have came up with two shuffling method that does the job. However, I'm not sure which ...
2
votes
2answers
98 views

Is this a reasonable algorithm for shuffling cards?

So I based my "algorithm" on the poke method defined by Persi Diaconis. You start with the card at the bottom of a given deck and then poke the top card into a random position in the deck. At first ...
2
votes
1answer
198 views

Fisher-Yates shuffle in Haskell

This is the Haskell version of my recursive Fisher-Yates shuffle in JS. ...
2
votes
1answer
146 views

Securely shuffling an array with 75 numbers in Go

I have a SHA512 hex string consisting of my random input and that of the user. Since rand.Seed only accepts a int64 I can never ...
2
votes
2answers
137 views

Sudoku generator using seed Sudoku

I have created a Sudoku generator in Java. Here I am using a basic solved sudoku as seed and by transposing it and shuffling its row and columns I get a new solved sudoku. ...
2
votes
1answer
1k views

Shuffle deck of cards in JavaScript

I know randomness in programming can be a deep topic, and searching the topic seems to result in Fisher-Yates being the best method, but I'm curious what people would say about this method. Basically,...
2
votes
1answer
2k views

Round Robin Tournament

RoundRobin is an implementation of the Round-robin style tournament: ...
2
votes
0answers
41 views

Generate sample of permuted sequences with non-repeating elements

I have a very long sequence of letters (>20000 elements long). I want to permute them so that I have another sequence using the same letters but in a different order but still with the property of no ...
1
vote
2answers
7k views

Logic for shuffling sliding puzzle

I'm working on a sliding puzzle, one little project as a hobby, and yesterday I thought that instead of working on an algorithm to figure out a solved puzzle, it would be easier to make an algorithm ...
1
vote
2answers
101 views

Randomly generate set of size M from array of size N

The following algorithm attempts to randomly generate a set of size M from an array of size N. It is not based on Knuth Fisher Yates shuffle, but could someone verify its correctness? ...
1
vote
3answers
363 views

Deck Shuffling Method

Just wondering if you guys think this is a good way to shuffle a deck or a bad way. Updated to show the GetRandom function as requested. ...
1
vote
1answer
165 views

Shuffling an array of cards

I have a deck of flashcards that I want to shuffle. Here's the method I'm using to shuffle them: ...
1
vote
2answers
112 views

Fisher-Yates Shuffle

This is a cut-and-dried Fisher-Yates implementation. As not typically a JS developer, I've tried to incorporate as many best practices as I can. I would appreciate any input as to make it conform to ...
1
vote
2answers
42 views

Shuffling many collections by folding over a numeric range

Often, I find myself folding over a range object if I need to repeatedly transform something. This, to me though, feels like an abuse of ...
1
vote
1answer
95 views

Increase efficiency of card-ordering program

As mentioned in @rolfl comment. What this program does is that it "resequences the cards using a fixed system and count the number of times the resequencing happens before the output is the same as ...
1
vote
1answer
301 views

Fisher-Yates shuffle Java implementation

This is my attempt at an implementation of the modern Fisher-Yates shuffle in Java. I'm not sure if it can be made more efficient, but I did my best to make it as simple as possible, and I learned how ...
1
vote
1answer
239 views

Shuffling sections of an ordered list based on tuple values

I have a list as follows and I want to shuffle the elements that have the same frequency while keeping the elements with different frequencies in the correct positions. The code below works; however, ...
1
vote
1answer
425 views

Shuffle a string in a repeatable way

The following function is designed to accept a string of characters and an integer. The function returns a string that's a reordered version of the original string. The reordering process is ...
1
vote
2answers
81 views

Shuffle data simulation

Is the following procedure good for shuffling data in general (not just for JavaScript)? ...
1
vote
1answer
43 views

Create a collection of binaries with random set positions

I would like to create a collection of binaries with n set bits and total length should be between n and 31; also those set bits ...
1
vote
1answer
152 views

ShuffleBag (Fisher-Yates + PcgRandom)

Anything that could be done better here? ...
1
vote
0answers
22 views

Implementation of GNU shuf(1) now supporting nul characters

Some time ago, I implemented shuf(1), but it had an issue: it ignored nul characters in the input. This new version tries to solve this problem (but uses the ...
1
vote
0answers
337 views

Seeded array shuffle

This should be relatively simple, but I want to know if I've done the randomness bit correctly. ...
0
votes
2answers
2k views

Shuffle Symfony entities

I've got an object $contest which is a Symfony entity that has some other entities assigned. I can get them by ...
0
votes
1answer
315 views

Updating MySQL with shuffled numbers between 1 and 50

I need to assign a number to each userId. I think this is too much of a query for updating. Is it possible to reduce the number of queries, or is it okay? ...
0
votes
1answer
594 views

Shuffle array without duplicates

I made a function about random backgrounds And those images will unique as possible. (Shuffle again after all gone) My steps is : Setup the array Shuffle it Do function (check if ...
0
votes
2answers
188 views

Three Cards Trick - Assigning random number to the cards

At first I have three cards like this: ___ ___ ___ | | | | | | | A | | A | | Q | |___| |___| |___| and then I shuffle them to this: ...

1
2