# Generate a deck of cards

Here's an array representing a standard deck of cards, including two Jokers.

[
"AS", "2S", "3S", "4S", "5S", "6S", "7S", "8S", "9S", "10S", "JS", "QS", "KS",
"AD", "2D", "3D", "4D", "5D", "6D", "7D", "8D", "9D", "10D", "JD", "QD", "KD",
"AH", "2H", "3H", "4H", "5H", "6H", "7H", "8H", "9H", "10H", "JH", "QH", "KH",
"AC", "2C", "3C", "4C", "5C", "6C", "7C", "8C", "9C", "10C", "JC", "QC", "KC",
"J", "J"
]


It's composed in this manner:

• There are four suits; hearts, spades, diamonds, and clubs (H, S, D, C).
• Each suit has one card for the numbers 2 to 10, plus 4 'picture' cards, Ace, Jack, Queen, and King (A, J, Q, K).
• For each combination of suit and value, there should be one item in the array, which is a string, and is made up of the value followed by the suit (Whitespace between these is permitted).
• On top of that, there are two Joker cards ('J').
• Write in any language you please.
• Golf it up! Try to produce this output in the smallest number of bytes.
• It does not matter what order the output is in.
• I was just wondering if you could get 23456789 by multiplying 2 smaller numbers... only to discover it's prime! Commented Jun 11, 2018 at 11:57
• @match Since the order of the output doesn't matter, maybe you can still create it with smaller numbers by ending it with 2 or 4 or anything else so it isn't a prime anymore. Commented Jun 11, 2018 at 13:19
• The playing field isn't very level when you've excluded a majority of languages
– Jo King
Commented Jun 12, 2018 at 9:55
• Rules in comments don't count. If we cannot print the result to STDOUT (and that's a big if, as it overrides our defaults for I/O and prevents languages without functions and string arrays from participating), that rule has to be stated explicitly in the challenge spec. Commented Jun 12, 2018 at 15:05
• That doesn't rule out a string representation of such an array, which could be printed to STDOUT. If not for the comment section, I never would have guessed this wasn't allowed. Commented Jun 12, 2018 at 23:50

{{i}ddd}iiiic{d}iiic{ddd}dddddc{iiii}iicddddddc{ddd}ddddddc{iiii}iicddc{dddd}c{iiii}iic{i}dc{ddddd}dc{iiiii}dc{d}ddddc{ddd}dddddc{iiiii}dc{d}dddc{ddd}ddddddc{iiiii}dc{d}ic{dddd}c{iiiii}dciic{ddddd}dc{iiii}iiic{d}iic{ddd}dddddc{iiii}iiic{d}iiic{ddd}ddddddc{iiii}iiicdddc{dddd}c{iiii}iiic{i}ddc{ddddd}dc{iii}iiiciic{ddd}dddddc{iii}iiiciiic{ddd}ddddddc{iii}iiic{i}dddc{dddd}c{iii}iiic{ii}ddc{ddddd}dc{ii}ddc{ii}dddc{ddd}dddddc{ii}ddc{ii}ddc{ddd}ddddddc{ii}ddc{ii}iic{dddd}c{ii}ddc{iii}iiic{ddddd}dc{ii}dc{i}iiiiiic{ddd}dddddc{ii}dc{ii}dddc{ddd}ddddddc{ii}dc{ii}ic{dddd}c{ii}dc{iii}iic{ddddd}dc{ii}c{i}iiiiic{ddd}dddddc{ii}c{i}iiiiiic{ddd}ddddddc{ii}c{ii}c{dddd}c{ii}c{iii}ic{ddddd}dc{ii}ic{i}iiiic{ddd}dddddc{ii}ic{i}iiiiic{ddd}ddddddc{ii}ic{ii}dc{dddd}c{ii}ic{iii}c{ddddd}dc{ii}iic{i}iiic{ddd}dddddc{ii}iic{i}iiiic{ddd}ddddddc{ii}iic{ii}ddc{dddd}c{ii}iic{iii}dc{ddddd}dc{ii}iiic{i}iic{ddd}dddddc{ii}iiic{i}iiic{ddd}ddddddc{ii}iiic{ii}dddc{dddd}c{ii}iiic{iii}ddc{ddddd}dc{ii}iiiic{i}ic{ddd}dddddc{ii}iiiic{i}iic{ddd}ddddddc{ii}iiiic{i}iiiiiic{dddd}c{ii}iiiic{iii}dddc{ddddd}dc{ii}iiiiic{i}c{ddd}dddddc{ii}iiiiic{i}ic{ddd}ddddddc{ii}iiiiic{i}iiiiic{dddd}c{ii}iiiiic{ii}iiiiiic{ddddd}dc{ii}dddcdc{ii}dc{ddd}dddddc{ii}dddcdc{ii}c{ddd}ddddddc{ii}dddcdc{ii}iiiic{dddd}c{ii}dddcdc{iii}iiiiic{ddddd}dc{iiii}iic{dddd}ddc{iiii}iic


Try it online!

• This looks quite a lot longer than the generated text. Am I missing something? Commented Mar 22, 2021 at 10:34
• @AJFaraday Deadfish~ is a very inconvenient lanugage. See the wiki Commented Mar 23, 2021 at 4:27
• WHYYYYYYYYYYYYY! Commented Mar 23, 2021 at 13:01
• Why not? I didn't write this by hand. Commented Mar 23, 2021 at 19:43

# Vyxal, 24 bytes

₀ɾḢ«∧9₂«fJ«¬⟩C«Ẋvṅ‛jjfJɾ


Try it Online!

## How?

₀ɾḢ«∧9₂«fJ«¬⟩C«Ẋvṅ‛jjfJɾ
₀ɾ                       # Push a list in the range [1, 10]
Ḣ                      # Remove the first: [2, 3, 4, ..., 10]
«∧9₂«                 # Push compressed string "jqka"
fJ               # Convert to list of characters and add to the other list: [2, 3, 4, ..., 10, "j", "q", "k", "a"]
«¬⟩C«           # Push compressed string "hsdc"
Ẋ         # Cartesian product of list and string: [[2, "h"], [2, "s"], ..., ["a", "c"]]
vṅ       # Join each together: ["2h", "2s", ..., "ac"]
‛jjf   # Push string "jj" and convert to list of characters: ["j", "j"]
J  # Append: ["2h", "2s", ..., "ac", "j", "j"]
ɾ # Uppercase each: ["2H", "2S", ..., "AC", "J", "J"]


"J":"J":[c++[s]|c<-"10":map pure"AJQK23456789",s<-"SDHC"]


Try it online!

# Retina, 49 42 bytes


AJQK2345678910
1?.
$0H,$0S,$0D,$0C,
$J,J Credit to @mazzy's comment on my Java answer. -7 bytes thanks to @ovs. Try it online. Explanation: Start with "AJQK2345678910":  AJQK2345678910 For each character (with "10" as single character): Replace it with "cH,cS,cD,cC" where c is this character: 1?.$0H,$0S,$0D,$0C,  And append "J,J" $
J,J

• You can shorten this by 4 bytes by removing capturing groups and replacing $1 with $&.
– ovs
Commented Jun 11, 2018 at 12:43
• 42 bytes
– ovs
Commented Jun 11, 2018 at 12:46
• @ovs Thanks. Was about to remove the parenthesis at (1?.) and use $0, but the appending of J,J is certainly shorter. Figured it would be possible, but I don't golf that often in Retina, so didn't knew how to append and hadn't had to time to search in the docs more thoroughly. PS: What's the difference between $& and $0 in this case, if there is any? Commented Jun 11, 2018 at 12:58 • It seems like there is no difference, but $& is used more often in the Retina docs, so I got used to it.
– ovs
Commented Jun 11, 2018 at 13:57
• $& comes from Perl, where it is the string matched by the last successful pattern match. (In Perl 6, you would use $/ with the prefix stringification op ~ instead) Commented Jun 11, 2018 at 17:41

# VBA + RegExp, 135 bytes

A declared function that takes no input and outputs to the out var, o.

This subroutine depends upon the Microsoft VBScript Regular Expression 5.5 reference.

Sub a(o)
Set r=New RegExp
r.Global=1
r.Pattern="(\w+)"
o=Split(r.Replace("A 2 3 4 5 6 7 8 9 10 J Q K","$1S$1H $1D$1C")&" J J")
End Sub


Note: The terminal " on line 4 is not counted in the bytecount as it is not necessary and is only included for SO's syntax highlighting

# 8th, 156152 149 bytes

Code

[] ( >s a:push ) 2 10 loop ["J","Q","K","A"] a:+ ( nip dup ["C","D","S","H"] ( nip s:+ >r dup ) a:each drop ) a:each ["J","J"] ( r> a:push ) 52 times


Array result is available on TOS

Output

["J","J","AH","AS","AD","AC","KH","KS","KD","KC","QH","QS","QD","QC","JH","JS","JD","JC","10H","10S","10D","10C","9H","9S","9D","9C","8H","8S","8D","8C","7H","7S","7D","7C","6H","6S","6D","6C","5H","5S","5D","5C","4H","4S","4D","4C","3H","3S","3D","3C","2H","2S","2D","2C"]


Ungolfed code

\ make array ["2","3","4","5","6","7","8","9","10"]
[] ( >s a:push ) 2 10 loop

\ make array ["2","3","4","5","6","7","8","9","10","A","J","Q","K"]
["J","Q","K","A"] a:+

\ make 13 cards for each suit and store each card on r-stack
( nip dup ["C","D","S","H"] ( nip s:+ >r dup ) a:each drop ) a:each

\ make array result reading previous cards from r-stack
["J","J"] ( r> a:push ) 52 times

\ array result is available on TOS. Display it and get rid of intermediate stuff
. cr
reset


# MATLAB R2018a, 82 57 bytes

Thanks to @David:

s=["A" 2:10 "J" "Q" "K"]+["D";"S";"H";"C"];[s(:);"J";"J"]


My old code:

X=["J","J"];for n=["A",2:10,"J","Q","K"]for s=["S","H","C","D"]X=[X,n+s];end;end;X


I figure it doesn't need an explanation but in case someone's interested:

X=["J","J"] // Set up first two Jokers
for n=["A",2:10,"J","Q","K"] // Set up array for A, 2, 3... to K
for s=["S","H","C","D"] // Set up suits
X=[X,n+s]; // "Glue" value and suit together and add to array
end
end
X // Print out the result


Output:

X =

1×54 string array

Columns 1 through 11

"J"    "J"    "AS"    "AH"    "AC"    "AD"    "2S"    "2H"    "2C"    "2D"    "3S"


Columns 12 through 22

"3H"    "3C"    "3D"    "4S"    "4H"    "4C"    "4D"    "5S"    "5H"    "5C"    "5D"


Columns 23 through 33

"6S"    "6H"    "6C"    "6D"    "7S"    "7H"    "7C"    "7D"    "8S"    "8H"    "8C"


Columns 34 through 43

"8D"    "9S"    "9H"    "9C"    "9D"    "10S"    "10H"    "10C"    "10D"    "JS"


Columns 44 through 54

"JH"    "JC"    "JD"    "QS"    "QH"    "QC"    "QD"    "KS"    "KH"    "KC"    "KD"

• +1, I didn't know about using " for strings! This can be shortened in newer version of Matlab (=>2016b) s=["A" 2:10 "J" "Q" "K"]+["D";"S";"H";"C"];[s(:);"J";"J"] Commented Jun 13, 2018 at 21:20

# Bash (if Unicode is allowed), 45 bytes

echo -e \\U1F0{{A..D}{{1..9},{A..E}},{CF,DF}}


...produces:

🂡 🂢 🂣 🂤 🂥 🂦 🂧 🂨 🂩 🂪 🂫 🂬 🂭 🂮 🂱 🂲 🂳 🂴 🂵 🂶 🂷 🂸 🂹 🂺 🂻 🂼 🂽 🂾 🃁 🃂 🃃 🃄 🃅 🃆 🃇 🃈 🃉 🃊 🃋 🃌 🃍 🃎 🃑 🃒 🃓 🃔 🃕 🃖 🃗 🃘 🃙 🃚 🃛 🃜 🃝 🃞 🃏 🃟


Try it online!

This should work wherever Unicode is supported (ex: LANG=en_US.UTF8, not LANG=C). I'm not sure, however, if this meets the conditions of the rules. In particular:

For each combination of suit and value, there should be one item in the array, which is a string, and is made up of the value followed by the suit (Whitespace between these is permitted).

The Unicode answer has one string per element, and the images indeed show a value followed by a suit. The example output, however, shows two separate chars per element, so there's room for doubt.

If the Unicode approach is disallowed, the code can be easily trimmed down to 34 bytes:

d=({A,K,Q,J,{10..2}}{S,H,D,C} J J)


Try it online!

...but that is no shorter than the existing answer by glenn jackman (albeit sorted).

Regardless, Unicode is a technique worth mentioning. If you're dealing out a deck of cards, you might as well use the nice little images which are probably already on your computer, even in a text-mode terminal.

As for the question about the rules, I think the best answer is for someone to develop a question format which intrinsically includes an automated unit test. Maybe someday...

• Welcome to the site. Unlike other forums all answers must include a complete solution to the problem, and I think you are correct that this does not technically fit the specifications of the problem. If you would like to add a complete solution to your answer you can do that (and keep your partial solution as a bonus) but without a complete solution answers are subject to deletion. Commented Jul 9, 2018 at 17:05
• Anyways, the unicode solution you have it prints out the knight card. Commented Jul 23, 2018 at 22:57

# Gol><>, 46 44 bytes

"CDSH"4F:j9FL2+noao|j"AKQJ"4F$ooao||S"JnJ";  Try it online! Edit: Saved 2 bytes thanks to Jo King Explanation: "CDSH"4F:j9FL2+noao|j"AKQJ"4F$ooao||S"JnJ";

"CDSH"                                        //Init the 4 suites
4F                                      //Loop to iterate over the 4 suites
:j                                    //Pop a copy of the current suite into the next loop
9FL2+noao|                         //Loop for the output of cards 2-10
j                         //Pass current suite into next loop & pop it from the stack
"AKQJ"                   //Init the 4 pictures
4F$ooao| //Loop 4 times to output the picture cards | //Jump back to the for loop to iterate over all suites S"JnJ"; //Output the two J and terminate programm  # C (gcc), 86 bytes f(i){for(i=54;i--;)printf(i<52?"1%c%c "+(i>3):"J ","023456789JQKA"[i/4],"HSDC"[i%4]);}  Try it online! # MASM 5 MACRO (x86 machine code), 109 100 bytes D LABEL BYTE IRPC r,234567890JQKA IRPC s,DSHC IF'&r'EQ'0' DB'1' ENDIF DB'&r','&s ' ENDM ENDM DB'J J'  Since machine code has no formal definition for "an array of variable length strings", this returns the elements as characters in contiguous memory, delimited by a separator byte (20H) with the label D as a pointer to the location in memory. Obviously, this would all be a lot simpler and smaller (76 bytes) if we could use 'T' for 10, which would make all cards exactly 2 bytes in size and simply be an indexable array of DW (double-words). That's your Kolmogorov rub I suppose! Here's a short test program that shows one possible way this could be utilized: MOV DX, OFFSET D MOV AH, 9 INT 21H MOV AH, 4CH INT 21H  Output 2D 2S 2H 2C 3D 3S 3H 3C 4D 4S 4H 4C 5D 5S 5H 5C 6D 6S 6H 6C 7D 7S 7H 7C 8D 8S 8H 8C 9D 9S 9H 9C 10D 10S 10H 10C JD JS JH JC QD QS QH QC KD KS KH KC AD AS AH AC J J  # Factor + poker, 64 bytes <deck> hand>card-names [ "T""10"replace ] map { "J""J"} append .  Try it online! Factor has a poker vocabulary that gets most of the way there; just have to change T to 10 and add the jokers. # Rockstar, 129 99 bytes say "J J" cut "CHSD" in S while S roll S in X say 10+X cut "A23456789JQK" in V while V say roll V+X  Try it here (Code will need to be pasted in) say "J\nJ" :Output the jokers cut "CHSD" in S :Split "CHSD" into array S while S :While S is not empty roll S in X : Pop the first element into variable X say 10+X : Output 10 appended with X cut "..." in V : Split "A23456789JQK" into array V while V : While V is not empty say : Output roll V : Pop the first element from V +X : Append X  # CJam, 45 bytes "A"]8,2f+'0f+"10"a+"JQK"++"SDHC"m*::+["J"_]+p  Try it online! # Jelly, 24 bytes ⁵ḊṾ€;“AJQK”p“HSDC”;⁾JJẎ€  Try it online! # JavaScript (Node.js), 126 bytes [..."SDHC"].map(a=>Array.apply(0,Array(13)).map((b,i)=>(i==0?'A':i>9?'JQK'[i-10]:i+1)+a)).reduce((a,b)=>a.concat(b),['J','J'])  Try it online! # C# (.NET Core), 140 bytes x=>{var a=new string[54];a[0]=a[1]="J";int i=2;foreach(var s in"SDCH")foreach(var n in"023456789AJQK")a[i++]=(n=='0'?"10":n+"")+s;return a;}  Try it online! -10 bytes thanks to Kevin Cruijssen -1 byte by taking unused input -18 bytes thanks to Corak • You can remove the {} of the foreach, and .ToString() can be +"". Commented Jun 11, 2018 at 12:10 • 116 bytes by creating a port of my Java answer: o=>(new System.Text.RegularExpressions.Regex("(1?.)").Replace("AJQK2345678910","$1H,$1S,$1D,$1C,")+"J,J").Split(','). Credit to @mazzy's comment. Commented Jun 11, 2018 at 12:17 • @KevinCruijssen huh, I thought I needed the {} because of the nested foreach. Thanks! I'm not going to use your java port given it's such a drastically different approach, I'll let you post that yourself. Also just realised I can take unused input to shave a byte Commented Jun 11, 2018 at 12:33 • I wonder if something could be done with new[]{"J","J"}.Concat(from s in "SDCH" from n in "023456789AJQK" select (n=='0'?"10":n+"")+s);, but the using alone would probably make it unpractical. Commented Jun 11, 2018 at 14:31 • @Corak Ah, you're right the .ToArray() should be added for this particular challenge, in which case it's 119 bytes. But the System.Collections.Generic isn't necessary in this case. As you can see in the TIO I linked, with just the using System.Linq; it works, so only that one should be counted towards to byte-count. Commented Jun 12, 2018 at 11:49 # Red, 88 bytes foreach s{HSDC}[foreach c['A 2 3 4 5 6 7 8 9 10 'J 'Q 'K][prin c print s]]prin['J"^/"'J]  Try it online! ## As a list: # Red, 100 bytes d:[]foreach s{HSDC}[foreach c['A 2 3 4 5 6 7 8 9 10 'J 'Q 'K][append d rejoin[c s]]]append d["J""J"]  Try it online! # Stax, 21 bytes Å|R╦¥Ä└╥¿‼≈┴2½#d☺Iwa▐  Run and debug it Explanation: 9{^$m"AJQK"+"HSDC"|*'JQPm Full program, unpacked
Stack ([] is array, "" string '' char): empty
9{  m                     Map each element in range [1, 9]
^                         Increment
$Stringify Stack: ["2", "3", "4", "5", "6", "7", "8", "9", "10"] "AJQK"+ Add "AJQK" Stack: ["2", "3", "4", "5", "6", "7", "8", "9", "10", 'A', 'J', 'Q', 'K'] "HSDC" Push suits Stack: "HSDC" ["2", "3", "4", "5", "6", "7", "8", "9", "10", 'A', 'J', 'Q', 'K'] |* Cartesian join Stack: [["2", 'H'], ["2", 'S'], ..., "AH", "AS", ...] 'J Push "J" Stack: "J" [...] Q Peek and print with newline Stack: "J" [...] P Pop and print with newline Stack: [...] m Map, implicitly print each with a newline  # SimpleTemplate, 69 bytes This is a template-like language I've been developing, all written in PHP. The instructions on how to use it are available in the Github page. J J{@setx"SDHC","23456789JQKA"}{@eachx.1 asN}{@eachx.0}{@echo" ",N,_}  ## Ungolfed: J J {@set chars "SDHC", "23456789JQKA"} {@each chars.1 as number} {@each chars.0 suite} {@echo " ", number, suite} {@/} {@/}  Due to a series of bugs, this is not the most optimal solution. A shorter (non-working but should work) version below (51 bytes): J J{@each"23456789JQKA"asN}{@each"SDHC"} {@echoN,_}  This, however, doesn't work. # vim, 80 bytes aoA J Q K<C-V><ESC>:r !seq 2 10<C-V><CR>o<C-V><ESC>V10kJ:s/ /H /g<ESC> yy3P34lrSjrDjrC:g/./:norm dd@" oJ J<ESC>  <C-V> is 0x16. <CR> is 0x0d. <ESC> is 0x1B ### Annotated a " insert vim code into the buffer that: oA J Q K<C-V><ESC> " generates face cards :r !seq 2 10<C-V><CR>o<C-V><ESC> " generates 2-10 V10kJ " joins into one line :s/ /H /g<ESC> " adds suit (hearts) yy3P " make 3 copies of code 34lrSjrDjrC " change suit for each copy :g/./:norm dd@" " replace each line with the results from running it o J J<ESC> " Jokers  Try it online! # Google Sheets, 86 Bytes A worksheet function that returns an array of "cards" to the the calling cell and the 53 cells to its right. =Split(RegExReplace("A 2 3 4 5 6 7 8 9 10 J Q K","(\w+)","$1S $1H$1D $1C ")&" J J","  Note: This function ends with a trailing space # Twig, 83 82 bytes J J{%for I in(2..9)|merge('AKQJ'|split)%} {{I~'SDHC'|split|join(' '~I)}}{%endfor%}  This outputs the suits grouped by the "number". You can test it on: https://twigfiddle.com/lz9cuf Old version: # Julia, 63 bytes [["1"^(k<'1')*"$k$z"for k="A234567890JQK"for z="HSDC"];"J";"J"]  ## Explanation [ [ "1"^(k<'1') # "1" if k is lexicographically before '1' # which here only happens if k is '0' *"$k$z" # concatenated to k and z for k="A234567890JQK" # for k in ranks for z="HSDC" # and z in suits ] ;"J" # then concatenate 2 jokers ;"J" ]  # Yabasic, 123 bytes Dim r$(54)
r$(1)="J" r$(2)="J"
For i=0To 51
r$(i+3)=Mid$("JQKA2345678910",1+i/4,1+(i/4>=12))+Mid$("CDHS",Mod(i,4)+1,1) Next  Try it online! # Groovy, 6866 60 bytes This is my first stab at a golf challenge, hope I get everything right. 68 byte version [*2..10,*'AKQJ'.grep()].collectMany{n->'HSDC'.collect{n+it}}+['J']*2  66 byte version [*2..10,*'AKQJ'.grep()].inject([]){a,e->a+'HSDC'*.plus(e)}+['J']*2  Try it here 60 byte version 'HSDC'.grep().sum{[*2..10,*'AKQJ'.grep()]*.plus(it)}+['J']*2  Try it here • Welcome to Code Golf! Nice work! One thing, tho, it's usually preferable to add a link to an online interpreter so folks can verify your solution works. Here's one for your solution: groovyconsole.appspot.com/script/5194941521199104 (You might like to add that to your answer). Commented Jun 14, 2018 at 15:29 # Cjam, 29 26 bytes B,2>"AJQK"+"SDHC"m*"JJ"+N*  Try it online! Explanation: B,2> e# Generate the range [2, 10] "AJQK"+ e# add the list with "AJQK" e# which generates all the 13 cards "SDHC" e# Push the variants m* e# Cartesian product "JJ"+ e# Add 2 J's to the list N* e# And join the list items with newlines  Note: 1. The previous count was incorrect; it should be 29 instead of 28. 2. The challenge said the order doesn't matter, so 3 bytes off! # Plain TeX, 348 bytes It's just text printed as if it were an array, but that is close enough I think. It's not like TeX has native arrays anyway (although I do use some form of arrays in the code). Short answer: \newcount\i\let\c\csname\let\e\endcsname\let\t\the\def~#1,#2,#3{\expandafter\def\c#2\t#1\e{#3}}\i3 ~\i,a,K~\i,s,D\i4 ~\i,a,Q~\i,s,C\i5 ~\i,a,J~\i,s,S\i2 ~\i,a,A~\i,s,H\newcount\v[\loop\v2{\loop"\t\v\c s\t\i\e", \ifnum\v<10\advance\v1\repeat}{\loop"\c a\t\v\e\c s\t\i\e", \ifnum\v<5\advance\v1\repeat}\break\ifnum\i<5\advance\i1\repeat "J", "J"]\bye  Long answer, with comments as explanation: %First shorten some commands \let\c\csname \let\e\endcsname \let\t\the %then define the function todefine and fill the arrays \def ~#1,#2,#3{\expandafter\def\c #2\t#1\e{#3}} %main counter in this program \newcount\i \i3 %array a contains A, K, Q, J, the 'picture cards' %array s contains D, C, S, H, the suits %indexing is 2 to 5 so the same counter as for the 2...10 can be used ~\i,a,K ~\i,s,D \i4 ~\i,a,Q ~\i,s,C \i5 ~\i,a,J ~\i,s,S %2 is the last one as we want i to be 2 after this \i2 ~\i,a,A ~\i,s,H %the other counter \newcount\v %outer loop loops over the suits [\loop %2 is the starting point for the arrays and the numbers \v2 %brackets to ensure local use of \v %first loop iterates over the numbers { \loop %this prints v and the current suit "\t\v \c s\t\i\e", \ifnum\v<10 %\advance \v by 1 \advance\v1 \repeat } %...second loop over the picture cards { \loop "\c a\t\v\e \c s\t\i\e", \ifnum\v<5 \advance\v1 \repeat } %to prevent the output escaping the file on the right border \break \ifnum\i<5 \advance\i1 \repeat %then print the jokers "J", "J" ] \bye  # Pyth - 32 bytes K+r2hTc"JQKA"1\J\JJ"SDHC"VJVK+HN  Explanation: K+r2hTc"JQKA"1\J\JJ"SDHC"VJVK+HN K Assign variable K to r2hT Range from 2 to 10 plus 1 + Plus c"JQKA"1 Length 1 substrings of "JQKA" \J\J Print 1 character string "J" twice J"SDHC" Assign J to "SDHC" VJ For N in J VK For H in K +HN Implicitly print H+N  # PicoLisp, 181 171 bytes (replaced ifn with if) (setq c '(A 2 3 4 5 6 7 8 9 10 J Q K)) (de z (s l)(if (<> l NIL) (cons (pack (car l) s) (z s (cdr l))))) (setq d (conc (z 'C c) (z 'D c) (z 'H c) (z 'S c) (list "J" "J")))  Sample output: bash$ pil +
`