# 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

# Brain-Flak, 276 bytes

((((((((()()())){}{})())[][])<>()())(<()>))<>[][][]){(<>)((((([()()()])){}{})[()])()){(({}<>(<(({})<>)>)()))}{}{}(((((()()()){}())(<<>(({})<>)>)((()()())){}{})(<<>(({})<>)>)())(<<>(({})<>)>)(()()()){})<>({}<>)<>}<>{{({}((((()()()){}()){}){}()){}<>)<>}{}<>((()()()()()){})<>}<>


Try it online!

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


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

• You can forgo declaring v and index into the literal to shave some bytes off. Commented Aug 7, 2018 at 10:32
• Suggest i=13;i--; instead of i=0;i<13; and ,"KQJX98765432A"[i] instead of "A23456789XJQK"[i++] Commented Aug 10, 2018 at 3:36
• @ceilingcat what stops the loop? Commented Aug 17, 2018 at 15:49
• @Blacksilver the loop stops when i--==0 Commented Aug 17, 2018 at 16:20

# Kotlin, 76 bytes

("A2345678910JQK".replace(Regex("1?."),"$0C$0D $0H$0S ")+"J J").split(" ")


Try it online!

# 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


Try it online!

# 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.



Try it online!

## 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.)