RE: shuffling a deck of cards
- To: mathgroup at smc.vnet.net
- Subject: [mg31798] RE: [mg31768] shuffling a deck of cards
- From: "David Park" <djmp at earthlink.net>
- Date: Sun, 2 Dec 2001 04:25:26 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Peter, I Flattened your FullDeck statement. Needs["DiscreteMath`Permutations`"] Clubset = Array[clubs, 13]; Diamondset = Array[diamonds, 13]; Spadeset = Array[Spade, 13]; Heartset = Array[Heart, 13]; FullDeck = Sort[Join[{Heartset}, {Spadeset}, {Diamondset}, {Clubset}]] // Flatten; FullDeck[[RandomPermutation[52]]] {Heart[1], Heart[9], Heart[10], Spade[13], clubs[6], clubs[11], Heart[3], Heart[4], Heart[5], Spade[7], diamonds[2], diamonds[9], Spade[2], diamonds[5], clubs[5], Spade[6], Spade[12], Spade[4], diamonds[13], Spade[8], clubs[1], diamonds[6], Heart[7], diamonds[12], Spade[1], diamonds[4], Spade[3], diamonds[3], clubs[10], Heart[8], Spade[5], clubs[13], clubs[9], diamonds[11], Heart[2], clubs[12], diamonds[1], clubs[7], Heart[13], Heart[11], Heart[12], Heart[6], Spade[11], Spade[10], Spade[9], diamonds[7], clubs[2], clubs[8], diamonds[8], clubs[3], diamonds[10], clubs[4]} David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ > From: Peter Dimitriou [mailto:peterangelo at mindspring.com] To: mathgroup at smc.vnet.net > > To Whom it may concern, > > the following is a deck of cards that needs to be shuffled, how would > I do this using the Sort Command > > Clubset=Array[clubs, 13] > > {clubs[1],clubs[2],clubs[3],clubs[4],clubs[5],clubs[6],clubs[7],clubs[8], > clubs[9],clubs[10],clubs[11],clubs[12],clubs[13]} > > Diamondset=Array[diamonds, 13] > > {diamonds[1],diamonds[2],diamonds[3],diamonds[4],diamonds[5],diamonds[6], > > diamonds[7],diamonds[8],diamonds[9],diamonds[10],diamonds[11],diam > onds[12], > diamonds[13]} > > Spadeset=Array[Spade, 13] > > {Spade[1],Spade[2],Spade[3],Spade[4],Spade[5],Spade[6],Spade[7],Spade[8], > Spade[9],Spade[10],Spade[11],Spade[12],Spade[13]} > > Heartset=Array[Heart, 13] > > {Heart[1],Heart[2],Heart[3],Heart[4],Heart[5],Heart[6],Heart[7],Heart[8], > Heart[9],Heart[10],Heart[11],Heart[12],Heart[13]} > > FullDeck=Sort[Join[{Heartset},{Spadeset}, {Diamondset}, {Clubset}]] > > {{clubs[1],clubs[2],clubs[3],clubs[4],clubs[5],clubs[6],clubs[7],clubs[8], > clubs[9],clubs[10],clubs[11],clubs[12],clubs[13]},{diamonds[1], > > diamonds[2],diamonds[3],diamonds[4],diamonds[5],diamonds[6],diamonds[7], > diamonds[8],diamonds[9],diamonds[10],diamonds[11],diamonds[12], > diamonds[13]},{Heart[1],Heart[2],Heart[3],Heart[4],Heart[5],Heart[6], > Heart[7],Heart[8],Heart[9],Heart[10],Heart[11],Heart[12], > Heart[13]},{Spade[1],Spade[2],Spade[3],Spade[4],Spade[5],Spade[6], > Spade[7],Spade[8],Spade[9],Spade[10],Spade[11],Spade[12],Spade[13]}} > > How do I shuffle FullDeck using the Sort Command so it is all mixed > up? > > Peterangelo >