| Bytes | Lang | Time | Link |
|---|---|---|---|
| 098 | AWK | 250909T172525Z | xrs |
| 099 | Rockstar | 200914T163516Z | Shaggy |
| 064 | Factor + poker | 220514T121604Z | chunes |
| 084 | PostScript | 220514T110353Z | bartysla |
| 024 | Vyxal | 220513T190815Z | naffetS |
| 1318 | Deadfish~ | 210322T085301Z | emanresu |
| nan | Pyth | 200914T025451Z | Scott |
| nan | MASM 5 MACRO x86 machine code | 190109T195025Z | 640KB |
| 026 | Japt | 180611T112236Z | Shaggy |
| 023 | 05AB1E | 180611T093347Z | Kevin Cr |
| 076 | Tcl | 190109T114656Z | sergiol |
| 025 | Pyth | 180611T150329Z | user4854 |
| 127 | QBasic 4.5 | 180611T212458Z | steenber |
| 076 | Kotlin | 180810T005445Z | JohnWell |
| 129 | C gcc | 180709T173813Z | SIGSTACK |
| 169 | SMBF | 180807T151233Z | mbomb007 |
| 086 | C gcc | 180807T121752Z | gastropn |
| nan | 180611T173126Z | Brad Gil | |
| nan | Lua | 180721T195426Z | Visckmar |
| 276 | BrainFlak | 180725T052520Z | Jo King |
| 171 | PicoLisp | 180627T225508Z | Bruce Lu |
| 044 | Gol><> | 180715T222714Z | Gegell |
| 045 | Bash if Unicode is allowed | 180709T165519Z | William |
| 032 | Pyth | 180629T205753Z | Tornado5 |
| 057 | MATLAB R2018a | 180611T220203Z | Asinine |
| 097 | PHP | 180611T163315Z | Francisc |
| 348 | Plain TeX | 180615T132503Z | Simon Kl |
| 026 | Cjam | 180614T022217Z | Chromium |
| 060 | Groovy | 180614T152602Z | Marty Ne |
| 123 | Yabasic | 180613T171440Z | Taylor R |
| 063 | Julia | 180614T132523Z | eaglgene |
| 082 | Twig | 180612T120234Z | Ismael M |
| 197 | brainfuck | 180612T105631Z | Jo King |
| 114 | C# .NET | 180614T082804Z | Kevin Cr |
| 041 | Perl 5 | 180611T102502Z | Dom Hast |
| 149 | 8th | 180613T164523Z | Chaos Ma |
| 135 | VBA + RegExp | 180613T161444Z | Taylor R |
| 086 | Google Sheets | 180613T154731Z | Taylor R |
| 164 | Oracle SQL | 180613T114748Z | MT0 |
| 080 | vim | 180612T233039Z | Ray |
| 069 | SimpleTemplate | 180612T150121Z | Ismael M |
| 138 | C gcc | 180611T213738Z | Bruce Lu |
| 072 | Javascript ES6 | 180611T165854Z | MattH |
| 021 | Stax | 180612T110011Z | wastl |
| 061 | Ruby | 180612T110051Z | G B |
| 088 | Red | 180611T103720Z | Galen Iv |
| 133 | C gcc | 180611T143758Z | LambdaBe |
| 065 | R | 180611T123418Z | digEmAll |
| 034 | Bash | 180611T143526Z | glenn ja |
| 066 | R | 180611T161932Z | JayCe |
| 140 | C# .NET Core | 180611T103658Z | Mayube |
| 137 | MSSQL | 180611T162823Z | BradC |
| 056 | Powershell | 180611T095750Z | mazzy |
| 041 | J | 180611T140225Z | Galen Iv |
| 030 | K ngn/k | 180611T133640Z | ngn |
| 042 | Retina | 180611T123421Z | Kevin Cr |
| 075 | Java 10 | 180611T091421Z | Kevin Cr |
| 126 | JavaScript Node.js | 180611T124609Z | Luis fel |
| 075 | Befunge98 FBBI | 180611T115848Z | ovs |
| 024 | Jelly | 180611T120436Z | Erik the |
| 029 | APL Dyalog Unicode | 180611T105444Z | user4180 |
| 064 | Python 3 | 180611T085555Z | TFeld |
| 045 | CJam | 180611T105737Z | maxb |
| 118 | Batch | 180611T101617Z | Neil |
| 504 | brainfuck | 180611T094949Z | The rand |
| 057 | Haskell | 180611T092811Z | Angs |
| 060 | JavaScript ES6 | 180611T090043Z | Arnauld |
AWK, 98 bytes
END{split("A234567899JQK",a,X);for(a[10]++;i++<54;)print(i<3?"J":a[i%13+1]substr("SDHC",i%4+1,1))}
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
Factor + poker, 64 bytes
<deck> hand>card-names [ "T""10"replace ] map { "J""J"} append .
Factor has a poker vocabulary that gets most of the way there; just have to change T to 10 and add the jokers.
PostScript, 90 84 bytes
Output as an array of strings on the stack.
00000000: 5b28 4443 4853 297b 2f64 923e 9233 284a [(DCHS){/d.>.3(J
00000010: 514b 4132 3334 3536 3738 3929 7b2f 6a92 QKA23456789){/j.
00000020: 3e92 3332 92a5 9238 9238 3020 6a92 7831 >.32...8.80 j.x1
00000030: 2064 9278 7d92 497d 9249 2831 3044 2928 d.x}.I}.I(10D)(
00000040: 3130 4329 2831 3048 2928 3130 5329 284a 10C)(10H)(10S)(J
00000050: 2992 385d ).8]
Pre-tokenization (119 bytes):
[(DCHS){/d exch def(JQKA23456789){/j exch def 2 string dup dup 0 j put 1 d put}forall}forall(10D)(10C)(10H)(10S)(J)dup]
Try it online! (Pre-tokenized version as I don't know how to paste the tokenized file into TIO.)
Vyxal, 24 bytes
₀ɾḢ«∧9₂«fJ«¬⟩C«Ẋvṅ‛jjfJɾ
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"]
Deadfish~, 1318 bytes
{{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
Pyth, 30 29 31 bytes
Current
+,K\JKsM*+tST[\AK\Q\K)[\H\D\C\S
Previous:
+,K\JK*+tST[\AK\Q\K)[\H\D\C\S
+,K\JK*+tS10[\AK\Q\K)[\H\D\C\S
Explanation:
+,K\JKsM*+tS10[\AK\Q\K)[\H\D\C\S
,K\JK Create a tuple ('J', 'J'), meanwhile assign 'J' to K
+tS10[\AK\Q\K) Create a range from 2-10 and append [A, J, Q, K] (K = 'J')
[\H\D\C\S Create range [H, D, C, S]
sM* Get the Cartesian product of {Num Range} & {Suit Range}, then join them as a string
+ Join the jokers onto the result.
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
Japt, 32 30 26 bytes
'J²¬c"JQKA"¬c9õÄ)ï+"CHSD"q
'J²¬c"JQKA"¬c9õÄ)ï+"CHSD"q
'J :Literal "J"
² :Repeat twice
¬ :Split
c :Concatenate
"JQKA"¬ : Split "JQKA"
c : Concatenate
9õ : Range [1,9]
Ä : Add 1 to each
) : End concatenation
ï : Cartesian Product
"CHSD"q : Split "CHSD"
+ : Join each pair to a string
05AB1E, 28 27 25 24 23 bytes
2TŸ.•-Ÿ•S«.•ôì•âJ„jjS«u
-1 byte thanks to @Emigna removing the S after "HSDC", because â does this implicitly.
Explanation:
2TŸ # Push list in the range [2,10]: [2,3,4,5,6,7,8,9,10]
.•-Ÿ• # Push compressed string "ajqk"
S # Convert it to a list of characters: ["a","j","q","k"]
« # Merge the two lists together: [2,3,4,5,6,7,8,9,10,"a","j","q","k"]
.•ôì• # Push compressed string "cdhs"
â # Cartesian product of each (pair each character of both lists):
# [[2,"a"],[2,"d"],[2,"h"],...,["k","d"],["k","h"],["k","s"]]
J # Join each pair together to a single string:
# ["2a","2d","2h",...,"kd","kh","ks"]
„jjS # Push string "jj", and convert it to a list of characters: ["j","j"]
« # Merge both lists together:
# ["2a","2d","2h",...,"kd","kh","ks","j","j"]
u # Convert everything to uppercase:
# ["2A","2D","2H",...,"KD","KH","KS","J","J"]
# (and output the result implicitly)
See this 05AB1E tip of mine (section How to compress strings not part of the dictionary?) to understand why .•-Ÿ• is "ajqk" and .•ôì• is "cdhs".
Tcl, 76 bytes
lmap n {S C H D} {lmap v {A K Q J 2 3 4 5 6 7 8 9 10} {puts $v$n}}
puts J\nJ
Pyth, 26 25 bytes
+ B\JsM*+tSTc"JQKA"1"CDHS
Saved a byte thanks to hakr14.
Try it here
Explanation
+ B\JsM*+tSTc"JQKA"1"CDHS
tST Get the range from 2 to 10...
+ c"JQKA"1 ... plus the list ['J', 'Q', 'K', 'A'].
* "CDHS Take the Cartesian product with the suits.
sM Stick the ranks and suits together.
+ B\J Add the jokers.
QBasic 4.5, 114 142 127 bytes
dim r$(54)
FOR i=1TO 52
m=i MOD 13
r$(i)=MID$("JQKA2345678910",1+m,1-(m=12))+MID$("CDHS",(i-1)\13+1,1)
NEXT
r$(53)="J
r$(54)="J
Release Notes:
- V1.0 Initial deploy
- V1.1 Misread the challenge requirements, so switched to a more expensive array
r$. All the rest of the code is pretty much the same. - V1.2 Suggestions from @TaylorScott lead to a complete rewrite saving 15 bytes!
Sample output
If we add this snippet to our code, we can see what is put into r$:
for i = 1 to ubound(r$)
?r$(i)
next
QC
KC
AC
2C
3C
4C
5C
6C
7C
8C
9C
10C
JC
QD
KD
AD
[... snip ...]
6S
7S
8S
9S
10S
JS
J
J
But how? Well, let me tell you:
dim r$(54) ' create a 54-slot array for our results
FOR i=1TO 52 ' Loop through the numbers 1-52 in var i
m=i MOD 13 ' Take i mod 13 to select a value (saved as m)
' , and (not saved) i intdiv 13 to get a suit
r$(i)= ' assigns to slot i in the result array
MID$("JQKA2345678910" ' a substring from the string with all the values
,1+m ' from position 1-13 (13 % 13 = 0, but QBasic strings are 1-based.
' Hence the + 1)
,1-(m=12)) ' taking 1 char by default, and 2 for the Ten
' Note that m=12 evaluates to 0 for 0-11, and to -1 for 12
+ MID$("CDHS",(i-1)\13+1,1) ' and take 1 char from the suits-string
NEXT
r$(53)="J ' Then append 2 jokers
r$(54)="J ' These strings are auto-closed by the QBasic compiler.
Kotlin, 76 bytes
("A2345678910JQK".replace(Regex("1?."),"$0C $0D $0H $0S ")+"J J").split(" ")
C (gcc), 129 bytes
char*v[]={"A","2","3","4","5","6","7","8","9","10","J","Q","K"};main(i){for(i=0;i<13;)printf("%sS %1$sD %1$sH %1$sC ",v[i++]);puts("J J");}
C (gcc), 89 bytes
main(i){for(i=0;i<13;)printf("%cS %1$cD %1$cH %1$cC ","A23456789XJQK"[i++]);puts("J J");}
2018-09-16: -12 @gastropner
SMBF, 169 bytes
␀ represents a literal NUL byte \x00.
<[.<]␀J J HA HK HQ HJ H01 H9 H8 H7 H6 H5 H4 H3 H2 SA SK SQ SJ S01 S9 S8 S7 S6 S5 S4 S3 S2 DA DK DQ DJ D01 D9 D8 D7 D6 D5 D4 D3 D2 CA CK CQ CJ C01 C9 C8 C7 C6 C5 C4 C3 C2
This is the naive solution.
Because this program contains a NUL byte, there's no easy way to use TIO. Run this in the Python interpreter using
data = bytearray(b'<[.<]\x00J J HA HK HQ HJ H01 H9 H8 H7 H6 H5 H4 H3 H2 SA SK SQ SJ S01 S9 S8 S7 S6 S5 S4 S3 S2 DA DK DQ DJ D01 D9 D8 D7 D6 D5 D4 D3 D2 CA CK CQ CJ C01 C9 C8 C7 C6 C5 C4 C3 C2')
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]);}
Perl 6, 43 42 bytes
{|(|(2..10),|<A J Q K>X~ <S D H C>),|<J J>}
{|(|(^9+2),|<A J Q K>X~ <S D H C>),|<J J>}
Expanded:
{ # bare block lambda
|( # flatten into outer list
|( # flatten into left-side list for X~
^9 + 2
# 0+2 ..^ 9+2
# 2 ..^ 11
# 2 .. 10
),
| # flatten into left-side list for X~
< A J Q K >
X~ # cross using &infix:« ~ » (string concatenation)
<S D H C>
),
|< J J > # flatten two `J`s into outer list
}
Lua, 156 127 138 129 bytes
loadstring'r={"J","J"}for x=1,52 do p=x%4+1r[#r+1]=({"A",2,3,4,5,6,7,8,9,10,"J","Q","K"})[x%13+1]..("SDHC"):sub(p,p)end return r'
Based on Jo King's code. As he suggested in the comments, my original answer wasn't valid (I'm still learning how code golf works 😬), and linked a better and valid answer. Then I made it smaller.
Original solution (156 bytes):
r={}s="SDHC"c={"J","Q","K"}t=table.insert for x in s:gmatch"."do for y=1,13 do t(r,(y==1 and"A"or y>10 and c[y-10]or y)..x)end end for _=1,2 do t(r, "J")end
r={} -- initializes the result table
s="SDHC" -- initializes the suits' string, it's better to be a string because we're just looping through it
c={"J","Q","K"} -- initializes some of the special cards
t=table.insert -- stores the table.insert call inside the 't' variable
for x in s:gmatch"."do -- loops through the suits, calling each one 'x'
for y=1,13 do -- 'y' is the current card
t(r,(y==1 and"A"or y>10 and c[y-10]or y)..x) -- adds the card accompanied by the suit to the result ('r') table
-- y==1 and"A"or y>10 and c[y-10]or y means if we're at the first card, it's an "A", else if we're past the 10th card, it's a special card, else, it's the number itself
end
end
for _=1,2 do t(r, "J")end -- loop 2 times, adding a "J" to the result table
I just want to say that I'm new to this Code Golf stuff, so if I'm doing something wrong, feel free to tell me. I know this answer isn't one of the smallest, I just wanted to challenge myself.
If you have suggestions for reducing my code you can say too. :)
Brain-Flak, 276 bytes
((((((((()()())){}{})())[][])<>()())(<()>))<>[][][]){(<>)((((([()()()])){}{})[()])()){(({}<>(<(({})<>)>)()))}{}{}(((((()()()){}())(<<>(({})<>)>)((()()())){}{})(<<>(({})<>)>)())(<<>(({})<>)>)(()()()){})<>({}<>)<>}<>{{({}((((()()()){}()){}){}()){}<>)<>}{}<>((()()()()()){})<>}<>
Prints each card on its own line, with a leading newline.
Explanation:
((((((
((()()())){}{}) # Push 9 to represent 'C'
()) # Push 10 to represent 'D'
[][]) # Push 14 to represent 'H'
<>()())(<()>)) # Push 16, 0, 16 to the other stack to represent the Jokers
<>[][][]) # Push 25 to represent 'S'
{ # Loop over each suit
(<>) # Push 0 for a newline
((
((([()()()])){}{}) # Push -9 to represent '1'
[()]) # Push -10 to represent '0'
()) # Push -9 to use as a counter
{ # Loop 9 times to push the number cards
(({} # Store counter
<>(<(({})<>)>) #Push current suit and newline
())) # Decrement counter and push twice, once as the number
}{}{}
((((
(()()()){}()) # Push 7 as 'A'
(<<>(({})<>)>) # Push suit and newline
((()()())){}{})# Push 16 as 'J'
(<<>(({})<>)>) # Push suit and newline
()) # Push 17 as 'K'
(<<>(({})<>)>) # Push suit and newline
(()()()){}) # Push 23 as 'Q'
<>({}<>)<> # Push suit
}
<>
{ # Loop over all output
{ # Add 58 to each number
({}((((()()()){}()){}){}()){}<>)<>
}
{}<>((()()()()()){})<> # And turn 0s into newlines
}<> # Implicit output
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 +
: (load 'cards.l)
-> ("AC" "2C" "3C" "4C" "5C" "6C" "7C" "8C" "9C" "10C" "JC" "QC" "KC" "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" "AS" "2S" "3S" "4S" "5S" "6S" "7S" "8S" "9S" "10S" "JS" "QS" "KS" "J" "J")
: d
-> ("AC" "2C" "3C" "4C" "5C" "6C" "7C" "8C" "9C" "10C" "JC" "QC" "KC" "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" "AS" "2S" "3S" "4S" "5S" "6S" "7S" "8S" "9S" "10S" "JS" "QS" "KS" "J" "J")
:
Gol><>, 46 44 bytes
"CDSH"4F:j9FL2+noao|j"AKQJ"4F$ooao||S"J`nJ";
Edit: Saved 2 bytes thanks to Jo King
Explanation:
"CDSH"4F:j9FL2+noao|j"AKQJ"4F$ooao||S"J`nJ";
"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"J`nJ"; //Output the two J and terminate programm
Bash (if Unicode is allowed), 45 bytes
echo -e \\U1F0{{A..D}{{1..9},{A..E}},{CF,DF}}
...produces:
🂡 🂢 🂣 🂤 🂥 🂦 🂧 🂨 🂩 🂪 🂫 🂬 🂭 🂮 🂱 🂲 🂳 🂴 🂵 🂶 🂷 🂸 🂹 🂺 🂻 🂼 🂽 🂾 🃁 🃂 🃃 🃄 🃅 🃆 🃇 🃈 🃉 🃊 🃋 🃌 🃍 🃎 🃑 🃒 🃓 🃔 🃕 🃖 🃗 🃘 🃙 🃚 🃛 🃜 🃝 🃞 🃏 🃟
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)
...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...
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
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"
PHP, 108 99 97 Bytes
Code
<?php $r=[J,J];foreach([A,J,Q,K,2,3,4,5,6,7,8,9,10]as$t)
$r=array_merge($r,[H.$t,S.$t,D.$t,C.$t]);
Tried to use purely php funcions, but bytecount was lower with a loop :(
Output (using print_r)
Array
(
[0] => J
[1] => J
[2] => HA
[3] => SA
[4] => DA
[5] => CA
[6] => HJ
[7] => SJ
[8] => DJ
[9] => CJ
[10] => HQ
[11] => SQ
[12] => DQ
[13] => CQ
[14] => HK
[15] => SK
[16] => DK
[17] => CK
[18] => H2
[19] => S2
[20] => D2
[21] => C2
[22] => H3
[23] => S3
[24] => D3
[25] => C3
[26] => H4
[27] => S4
[28] => D4
[29] => C4
[30] => H5
[31] => S5
[32] => D5
[33] => C5
[34] => H6
[35] => S6
[36] => D6
[37] => C6
[38] => H7
[39] => S7
[40] => D7
[41] => C7
[42] => H8
[43] => S8
[44] => D8
[45] => C8
[46] => H9
[47] => S9
[48] => D9
[49] => C9
[50] => H10
[51] => S10
[52] => D10
[53] => C10
)
Edit
Thanks to @JoKing by suggesting change explode(" ","H$t S$t D$t C$t") for [H.$t,S.$t,D.$t,C.$t]
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
Cjam, 29 26 bytes
B,2>"AJQK"+"SDHC"m*"JJ"+N*
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:
- The previous count was incorrect; it should be 29 instead of 28.
- The challenge said the order doesn't matter, so 3 bytes off!
Groovy, 68 66 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
60 byte version
'HSDC'.grep().sum{[*2..10,*'AKQJ'.grep()]*.plus(it)}+['J']*2
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
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"
]
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:
- https://twigfiddle.com/jmkyza (83 bytes)
The output has a trailing space
brainfuck, 200 197 bytes
+[[<+>->++<]>]+<++++<<+++[->+++>+++++>+>+<<<<]>+.<<.>>.--<<<[->>+++<<]>>+>[<<.>.-.+>.<<.<<[>>>+.>.<<.<+<-]>[-<+>>>+<<]>>.>.<<.>+++++++++.>.<<.>+.>.<<.>++++++.>.,++++[-<-------->]>[[-<+>]>]<<[<]>>>]
Uses one negative cell (+1 bytes to fix), wrapping cells (lots o' bytes to fix) and 0 on EOF (+2 bytes to remove dependancy).
Outputs
J J 10H 2H 3H 4H 5H 6H 7H 8H 9H AH JH KH QH 10S 2S 3S 4S 5S 6S 7S 8S 9S AS JS KS QS 10D 2D 3D 4D 5D 6D 7D 8D 9D AD JD KD QD 10C 2C 3C 4C 5C 6C 7C 8C 9C AC JC KC QC
Explanation:
+[[<+>->++<]>] Sets the tape to powers of 2
TAPE: 1 2 4 8 16 32 64 128 0 0'
+<++++<<+++[->+++>+++++>+>+<<<<] Uses the 64 and the 128 to generate the suit letters
TAPE: 1 2 4 8 16 32 0' 73 83 68 67
I S D C
>+.<<.>>.--<< Prints the Jokers
<[->>+++<<]>>+> Uses the 16 to create 49
TAPE: 1 2 4 8 0 32 49 72' 83 68 67
H S D C
[ Loop over the suits
<<.>.-.+>.<<.<< Print the 10 card with a leading space
TAPE: 1 2 4 8' 0 32 49 Suit
[>>>+.>.<<.<+<-] Use the 8 to print the other 8 number cards
TAPE: 1 2 4 0' 8 32 57 Suit
>[-<+>>>+<<] Move the 8 back into place while also adding it to the 57
TAPE: 1 2 4 8 0' 32 65 Suit
>>.>.<<. Print the Ace
>+++++++++.>.<<. Print the Jack
>+.>.<<. Print the King
>++++++.>.<<. Print the Queen
TAPE: 1 2 4 8 0 32 81' Suit
>>, Clear the current suit
++++[-<-------->] Subtract 32 to get back to 49 (reusing the space is longer than just subtracting 32)
TAPE: 1 2 4 8 0 32 49 0' MoreSuits?
>[[-<+>]>]<<[<]>>> Shift all the remaining suits over one
TAPE: 1 2 4 8 0 32 49 Suit?'
] End on the character of the next suit and repeat
C# .NET, 114 bytes
o=>(new System.Text.RegularExpressions.Regex("1?.").Replace("AJQK2345678910","$0H,$0S,$0D,$0C,")+"J,J").Split(',')
Port of my Java answer (credit to @mazzy).
Interesting alternative of 119 bytes by @Corak.
using System.Linq;o=>new[]{"J","J"}.Concat(from s in"SDCH"from n in"A234567890JQK"select(n=='0'?"10":n+"")+s).ToArray()
If an System.Collections.Generic.IEnumerable<string> instead of string[] is an acceptable output, the trailing .ToArray() can be dropped so it becomes 109 bytes.
Explanation:
using System.Linq; // Required import for the `from .. in ..` and `select` parts
o=> // Method with empty unused parameter and string-array return-type
new[]{"J","J"} // Return a string-array containing two times "J"
.Concat( // And add:
from s in"SDCH" // Loop over the suits
from n in"A234567890JQK"
// Inner loop over the cards
select(n=='0'? // If the current card item is '0'
"10" // Use 10 instead
: // Else:
n+"") // Simply use the card item as is
+s)// And append the suit
.ToArray() // Convert the IEnumerable to an array
8th, 156 152 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
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
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
Oracle SQL, 164 bytes
Not a golfing language but...
SELECT CASE WHEN LEVEL>52THEN'J'ELSE DECODE(MOD(LEVEL,13),1,'A',11,'J',12,'Q',0,'K',MOD(LEVEL,13))||SUBSTR('HDSC',CEIL(LEVEL/13),1)END FROM DUAL CONNECT BY LEVEL<55
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
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.
C (gcc, clang), 138 bytes
#define p(c)putchar(c)
int main(){for(char*q,*r="CDHS";*r;r++)for(q="A234567890JQK";*q;q++)(48==*q)&&p(49),p(*q),p(*r),p(32);puts("J J");}
Approach is to encode the sequences in character arrays.
Sample Output
AC AD AH AS 2C 2D 2H 2S 3C 3D 3H 3S 4C 4D 4H 4S 5C 5D 5H 5S 6C 6D 6H 6S 7C 7D 7H 7S 8C 8D 8H 8S 9C 9D 9H 9S 10C 10D 10H 10S JC JD JH JS QC QD QH QS KC KD KH KS J J
Javascript (ES6) 77 74 72 bytes
This is a complete program.
`J,J,${[..."A23456789JQK",10].map(c=>[..."SDHC"].map(s=>c+s))}`.split`,`
Stax, 21 bytes
Å|R╦¥Ä└╥¿‼≈┴2½#d☺Iwa▐
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
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]
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"]
C (gcc), 126 137 133 bytes
#define S(X)"A"X,"2"X,"3"X,"4"X,"5"X,"6"X,"7"X,"8"X,"9"X,"10"X,"J"X,"Q"X,"K"X,
#define c (char*[54]){S("S")S("D")S("H")S("C")"J","J"}
+11 bytes to be more complete thanks to Jakob.
-4 bytes thanks to Zachary
Mostly abusing of preprocessor to compress the suits. Could probably be out-golfed, but is pretty efficient all things considered.
R, 65 bytes
c(outer(c('A',2:10,J<-'J','Q','K'),c('S','D','H','C'),paste),J,J)
-2 Bytes thanks to @Giuseppe and @JayCe suggestions
R, 67 66 bytes
c(paste(rep(c('A',2:10,J<-'J','Q','K'),4),c('S','D','H','C')),J,J)
Only one more byte than digEmAll's golfier solution. Inspired byGiuseppe's solution to this related challenge - the same Giuseppe who golfed one byte off by answer!
I'm posting separately since it's a slightly different approach taking advantage of the fact that 4 is not a divisor of 13 and that the output does not need to be in any particular order.
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;}
-10 bytes thanks to Kevin Cruijssen
-1 byte by taking unused input
-18 bytes thanks to Corak
MS-SQL, 137 bytes
SELECT v.value+s.value
FROM STRING_SPLIT('A-2-3-4-5-6-7-8-9-10-J-Q-K','-')v,STRING_SPLIT('H-S-D-C--','-')s
WHERE s.value>''OR v.value='J'
An array of values in SQL is returned as separate query rows. Uses the STRING_SPLIT function introduced in SQL 2016.
It includes the jokers by adding two "blank string" suits to take advantage of the existing "J" for Jack, then filtering out rows we don't want. Shorter than using UNION ALL statements to add the jokers.
Powershell, 63 61 59 56 bytes
-3 bytes: thanks ConnorLSW
2..10+'AJQK'[0..3]|%{"$_`H";"$_`S";"$_`D";"$_`C"};,'J'*2
K (ngn/k), 30 bytes
"JJ",/("AKQJ",$2+!9),'/:"SHDC"
!9 is the list 0 1 ... 8
2+!9 is the list 2 3 ... 10
$ to string
, concatenate
,'/: concatenate each with each right, i.e. Cartesian product; normally it's ,/:\: or ,\:/: but on the right we have only scalars ("SHDC"), so we can use ' instead of \:
"JJ",/ join (concat reduce) the list on the right using "JJ" as initial value for the reduction
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.
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
Java 10, 153 151 125 77 75 bytes
v->("AJQK2345678910".replaceAll("1?.","$0H,$0S,$0D,$0C,")+"J,J").split(",")
-28 bytes thanks to @OlivierGrégoire.
-50 bytes thanks to @mazzy.
Explanation:
v-> // Method with empty unused parameter and String-array return-type
"AJQK2345678910"
.replaceAll("1?.", // Replace every loose character (or "10" as single char)
"$0H,$0S,$0D,$0C,") // with "cH,cS,cD,cC,", where c is the character
+"J,J") // Append "J,J"
.split(",") // And split everything by commas
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'])
Befunge-98 (FBBI), 75 bytes
j4d*1-2k:d%4+1g:'0-!#v_>,d/1g,' ,!#v_3
CHSDA234567890JQK@;1'< ^,;,k2"J J" <
Program structure
At first, the stack is filled with 0's, and j does not jump over the initialisation. The initialisation pushes 4 * 13 = 52, which is the program counter. In the following iterations the trailing 3 causes the pointer to jump over this part.
1-2k:d%4+1g,d/1g,' ,!#v_ Main loop
1- decrement counter
2k: duplicate counter three times
d% counter mod 13 ...
4+ ... + 4 is the position of the card in the Data section
1g, get the card from row 1 and print it
d/ counter / 13 is the position of the suit in the Data section
1g, get the suit from row 1 and print it
' , print a space as seperator
! negate the counter (0 for non-zero, 1 for 0)
_ If the counter is 0, move West ...
#v ... and move to the termination
otherwise, continue with the next iteration
Code that prints 10:
'0-!#v_> Checks if Card is '0'
'0- subtract the '0' from the card
! negate (1 for '0', 0 for all other cards)
_ If card was '0', move West
#v and go South to print '10'
Else continue to go East
;1'< ^,; Prints '10'
< Go West
1' Push '1'
; Jump to ...
; ... the next semicolon
, Print '1'
^ Go back to the main loop
The '0' will be printed by the main loop
Termination:
@; ... ;,k2"J J" <
< Go West
"J J" Push "J J"
,k2 Print it
; Jump to ...
; ... the next semicolon
@ terminate the program
APL (Dyalog Unicode), 29 bytes
1 byte saved thanks to Probie by using 1+⍳9 instead of 1↓⍳10
'JJ',,'HCDS'∘.,⍨'AKJQ',⍕¨1+⍳9
This is a full program. In the TIO link, I have enabled boxing so that the individual elements of the array can be distinguished.
Here is the boxed output.
┌─┬─┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬───┬───┬───┬───┐
│J│J│AH│AC│AD│AS│KH│KC│KD│KS│JH│JC│JD│JS│QH│QC│QD│QS│2H│2C│2D│2S│3H│3C│3D│3S│4H│4C│4D│4S│5H│5C│5D│5S│6H│6C│6D│6S│7H│7C│7D│7S│8H│8C│8D│8S│9H│9C│9D│9S│10H│10C│10D│10S│
└─┴─┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴───┴───┴───┴───┘
'JJ', 2 jokers concatenated to
, the raveled form of
∘.,⍨ the matrix created by concatenating every combination of
'HCDS'this string against'AKJQ',this string with⍕¨the stringified forms of each of1+⍳9the numbers 2..10 (1 plus the range 1..9)
Python 3, 67 64 bytes
print(*[a+b for a in['10',*'A23456789JQK']for b in'CHSD'],*'JJ')
Python 2, 78 76 74 68 bytes
print['1'*(a<'1')+a+b for a in'A234567890JQK'for b in'CHSD']+['J']*2
Alt:
Python 2, 68 bytes
print[a+b for a in['10']+list('A23456789JQK')for b in'CHSD']+['J']*2
print['1'[a>'0':]+a+b for a in'A234567890JQK'for b in'CHSD']+['J']*2
saved
- -3 bytes, thanks to ovs
Batch, 118 bytes
@for %%s in (C D H S)do @(for /l %%r in (2,1,10)do @echo %%r%%s)&for %%r in (J Q K A)do @echo %%r%%s
@echo J
@echo J
brainfuck, 550 504 bytes
++++++++++[>+++>+++++>+++++++<<<-]>++>->[>+>+>+>+<<<<-]>----->++++.<<<<.>>>>.<<<<.>>>>>--->+++++++++++++<<<<<.-.+>>>>.<<<<<.>.-.+>>>>+.<<<<<.>.-.+>>>>++++.-----<<<<<.>.-.+>>>>>.<<<<<<.>>++++++++[-<+.>>>>.<<<<<.>.>>>>+.<<<<<.>.>>>>++++.-----<<<<<.>.>>>>>.<<<<<<.>>]>.>>.<<<<<.>>>>.>.<<<<<.>>>>+.>.<<<<<.>>>>++++++.>.<<<<<.>>>.>>+.<<<<<.>>>>.>.<<<<<.>>>>------.>.<<<<<.>>>>-.>.<<<<<.>>>.>>++++.<<<<<.>>>>.>.<<<<<.>>>>+.>.<<<<<.>>>>++++++.>.<<<<<.>>>.>>>.<<<<<<.>>>>.>>.<<<<<<.>>>>------.>>.<<<<<<.>>>>-.>>.
JavaScript (ES6), 62 60 bytes
f=n=>n>51?'JJ':[('JQKA'[k=n>>2]||k-2)+'CDHS'[n&3],...f(-~n)]
