html
html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<!--
♥️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!
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!
--->
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<script>main();</script>
</body>
</html>
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
body {
}
div {
width:20px; height:65px; display:inline-block; margin:2px;
}
img {
width:50px; height:65px;
}
input {
display:block; margin:20px auto;
}
Enter to Rename, Shift+Enter to Preview
js
js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var addr = [
[23022, 23004, 23006, 23008, 23010, 23012, 23014, 23016, 23018, 23020, 23024, 23028, 23026],
[22958,22938, 22940, 22942, 22944, 22946, 22948, 22950, 22952, 22954, 22960, 22966, 22964],
[22928, 22904, 22908, 22910, 22914, 22916, 22918, 22920, 22924, 22926, 22932, 22936, 22934],
[22992, 22968, 22972, 22974, 22976, 22978, 22980, 22982, 22986, 22988, 22994, 22998, 22996],
[23002, 23000, 23038]];
function getCard(addr){
var div = document.createElement("div");
var img = document.createElement("img");
div.setAttribute("id", "div");
div.appendChild(img);
document.body.appendChild(div);
img.setAttribute("src", "https://openclipart.org/download/"+addr+"/~.svg");
}
var addrList = [];
function newOrder(){
return function(){
var bunch1 = addrList.slice(0, (addrList.length/2));
var bunch2 = addrList.slice(addrList.length/2, addrList.length);
var i = 0;
while(i<addrList.length/2){
var x = getRandom(1,2);
switch(x){
case 1:
addrList[i+i] = bunch1[i];
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run