+ 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:
12 Réponses
+ 15
My solution in Java
https://code.sololearn.com/cullLUgQ2e5q/?ref=app
You can use it as an example!
+ 15
👉 shuffling in 52 loops , its damn possible ... see my code ☺☺👍
https://code.sololearn.com/cQ3Pz4iBJt7b/?ref=app
+ 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!
+ 10
Using Stream:
https://code.sololearn.com/cC6OtslMWpbz/?ref=app
+ 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.
+ 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!
+ 9
My try..
Input a number between 1 and 52 !
https://code.sololearn.com/cK97r0xewyeL/?ref=app
+ 8
My try, in AngularJs: https://code.sololearn.com/WxEpt47irMhI/?ref=app
+ 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
+ 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/
+ 6
Here's mine..
Thx for the challenge!
https://code.sololearn.com/Ww2GiXkEy9nd/?ref=app
+ 1
Hi