+ 19

♥️Challenge♥️ Shuffling a new deck of cards

Assume a new deck of cards is organized as follows: ♠️1, ♠️2, ..., ♠️10, ♠️J, ♠️Q, ♠️K, ♦️1, ♦️2, ..., ♦️10, ♦️J, ♦️Q, ♦️K, ♣️1, ♣️2, ..., ♣️10, ♣️J, ♣️Q, ♣️K, ♥️1, ♥️2, ..., ♥️10, ♥️J, ♥️Q, ♥️K Write a program to do the followings: 1. Generate a new deck of cards and print it nicely! 2. Shuffle and print it three times! For explanations see the following answer:

26th Dec 2017, 4:11 PM
Vahid Shirbisheh
Vahid Shirbisheh - avatar
12 Answers
+ 15
My solution in Java https://code.sololearn.com/cullLUgQ2e5q/?ref=app You can use it as an example!
26th Dec 2017, 4:14 PM
Vahid Shirbisheh
Vahid Shirbisheh - avatar
+ 15
👉 shuffling in 52 loops , its damn possible ... see my code ☺☺👍 https://code.sololearn.com/cQ3Pz4iBJt7b/?ref=app
27th Dec 2017, 4:05 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 14
Explanations: To shuffle a deck of cards you should divide it to two equal bunches and then combining these two bunches of cards in such a way that the order of each bunch should be preserved. The last condition means that if for instance ♦️J and ♠️10 are in the same bunch and ♠️10 is on the top of ♦️J, after combining two bunches ♠️10 should still be on the top of ♦️J. So, DO NOT confuse shuffling with randomly mixing cards!
26th Dec 2017, 4:13 PM
Vahid Shirbisheh
Vahid Shirbisheh - avatar
27th Dec 2017, 7:46 AM
LukArToDo
LukArToDo - avatar
+ 10
@Edgars Thank you for your effort. You have demonstrated a beautiful graphics. But your shuffle is not random. It is alternative replacement of cards . Please run my code to see a random shuffling.
30th Dec 2017, 1:18 PM
Vahid Shirbisheh
Vahid Shirbisheh - avatar
+ 9
@Gaurav Agrawal When you mix these two the order of each part should be preserved for example the following mixtures are valid 2,3,1,4,5,6,8 and 2,1,3,4,6,5,8 but the mixture 2,1,4, 5,3,6,8 is not a valid shuffle because before mixing 4 comes after 3 but after mixing 4 comes before 3!
27th Dec 2017, 9:49 AM
Vahid Shirbisheh
Vahid Shirbisheh - avatar
+ 9
My try.. Input a number between 1 and 52 ! https://code.sololearn.com/cK97r0xewyeL/?ref=app
30th Dec 2017, 8:10 PM
AZTECCO
AZTECCO - avatar
26th Dec 2017, 8:02 PM
Luc Hariman Randrianomenjanahary
Luc Hariman Randrianomenjanahary - avatar
+ 6
Here is my attempt.You can shuffle as many times as you need . Just input the no of shuffles you need. https://code.sololearn.com/cFRd8kQcuWkG/?ref=app
27th Dec 2017, 5:55 PM
Hamid
Hamid - avatar
+ 6
Ruby: https://code.sololearn.com/cEdW3e2vu7S9/ edit: riffle shuffle works more human now Inspired by this challenge, I did some experiments with various shuffling techniques (doesn't run well in playground because of time limits) https://code.sololearn.com/cTTxsXr8R1VJ/
28th Dec 2017, 2:51 PM
bedawang
bedawang - avatar
+ 6
Here's mine.. Thx for the challenge! https://code.sololearn.com/Ww2GiXkEy9nd/?ref=app
30th Dec 2017, 1:13 PM
Edgars Urbans
Edgars Urbans - avatar
+ 1
Hi
27th Dec 2017, 2:55 AM
Saty Meena
Saty Meena - avatar