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.
  • 2
    @KevinCruijssen that’s correct. The initial question specifies the numbers 2 to 10, and an array of strings as an output. – AJFaraday Jun 11 at 9:26
  • 15
    I was just wondering if you could get 23456789 by multiplying 2 smaller numbers... only to discover it's prime! – match Jun 11 at 11:57
  • 3
    @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. – Kevin Cruijssen Jun 11 at 13:19
  • 3
    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. – Dennis Jun 12 at 15:05
  • 7
    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. – Dennis Jun 12 at 23:50

58 Answers 58

JavaScript (ES6), 62 60 bytes


Try it online!

  • Smooth moves!!! – Code Whisperer Jun 11 at 14:46
  • I didn't know spread syntax existed until I read this -- very cool – logic8 Jun 15 at 17:29

Bash 43 34 bytes

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

Try it online!

  • 1
    9 bytes shorter – Digital Trauma Jun 11 at 17:34
  • I did not think braces were nestable. Thanks. – glenn jackman Jun 11 at 17:53
  • And here I was thinking "what language do I know that conveniently does direct products on lists of strings?" I didn't even think about good old glob! – aschepler Jun 13 at 1:21
  • 1
    Technically brace expansion is not a glob pattern, it is its own special syntax – glenn jackman Jun 14 at 3:19

brainfuck, 200 197 bytes


Try it online!

Uses one negative cell (+1 bytes to fix), wrapping cells (lots o' bytes to fix) and 0 on EOF (+2 bytes to remove dependancy).


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


+[[<+>->++<]>]  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
  • That more than 2.5 time shorter than my solution. Well done. – The random guy Jun 12 at 14:52

05AB1E, 28 27 25 24 bytes


Try it online.

-1 byte thanks to @Emigna removing the S after "HSDC", because â does this implicitly.


2TŸ"AJQK"S«    # [2,3,4,5,6,7,8,9,10,'A','J','Q','K']
"HSDC"         # "HSDC"
â              # Cartesian product of each (pair each character of both lists)
J              # Join each pair together to a single string
„JJS«          # Add two items "J" to the list

24 byte alternative of @Emigna:


Try it online.

brainfuck, 550 504 bytes


Try it online!

Old answer, also online!

Java 10, 153 151 125 77 75 bytes


-28 bytes thanks to @OlivierGrégoire.
-50 bytes thanks to @mazzy.

Try it online.


v->                      // Method with empty unused parameter and String-array return-type
   .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

APL (Dyalog Unicode), 29 bytes

1 byte saved thanks to Probie by using 1+⍳9 instead of 1↓⍳10


Try it online!

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.


'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 of

      • 1+⍳9 the numbers 2..10 (1 plus the range 1..9)
  • I've changed the indentation of your list in the explanation. It looked a bit weird with the two and three dots.. If that was intended for some reason, feel free to rollback. – Kevin Cruijssen Jun 11 at 11:31
  • @KevinCruijssen Thanks, I couldn't figure out how to do that, so I used multiple bullet points hah – Cows quack Jun 11 at 11:39
  • Yeah, I thought so, that's why I changed it. :) You need multiples of four leading spaces before the - to indent it. – Kevin Cruijssen Jun 11 at 11:51

Befunge-98 (FBBI), 75 bytes

j4d*1-2k:d%4+1g:'0-!#v_>,d/1g,' ,!#v_3
CHSDA234567890JQK@;1'< ^,;,k2"J J" <

Try it online!

Program structure

enter image description here

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


@; ... ;,k2"J J" <

                 <  Go West
           "J J"    Push "J J"
        ,k2         Print it
       ;            Jump to ...
 ;                  ... the next semicolon
@                   terminate the program

R, 65 bytes


Try it online!

-2 Bytes thanks to @Giuseppe and @JayCe suggestions

  • 1
    This was my exact answer, although I think I used double quotes instead of single quotes. – Giuseppe Jun 11 at 12:44
  • Sorry, have I double-posted your answer ? I checked but I couldn't find any R answer... – digEmAll Jun 11 at 13:14
  • Oh no I had just typed it all up myself in TIO before seeing yours :-) – Giuseppe Jun 11 at 13:26
  • 1
    Yes outer is definitely the way to go here! Although whitespace is premitted as per spec so you can save one byte by using paste. @Giuseppe too. – JayCe Jun 11 at 15:00
  • I pointed this out on JayCe's answer, but you can set x<-'J' inside the outer and then re-use x as a variable in the outermost c() statement to shave off a byte: Try it online! – Giuseppe Jun 11 at 18:03

Perl 5, 41 bytes


Try it online!

  • 1
    This has taught me something really interesting about globbing. Nice. – AmbroseChapel Jun 12 at 23:33

K (ngn/k), 30 bytes


Try it online!

!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

Powershell, 63 61 59 56 bytes

-3 bytes: thanks ConnorLSW

  • 1
    -3 using string to array for the first part : 2..10+'AJQK'[0..4]|%{"$_`H";"$_`S";"$_`D";"$_`C"};,'J'*2 – colsw Jun 11 at 14:43
  • 1
    cool! any idea how to remove ````? – mazzy Jun 11 at 14:57
  • 1
    as far as I know that's the cheapest way to break up a variable in a string, I took a look at a loop but it's more expensive by 2 chars to do it that way. – colsw Jun 11 at 14:59

Python 3, 67 64 bytes

print(*[a+b for a in['10',*'A23456789JQK']for b in'CHSD'],*'JJ')

Try it online!

Python 2, 78 76 74 68 bytes

print['1'*(a<'1')+a+b for a in'A234567890JQK'for b in'CHSD']+['J']*2

Try it online!


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


  • -3 bytes, thanks to ovs
  • That's a pretty thorough answer... – AJFaraday Jun 11 at 9:15
  • 64 bytes – ovs Jun 11 at 11:07
  • @ovs, thanks :) – TFeld Jun 11 at 11:20
  • If we don't have to use print, can't we do [*[a+b for a in['10',*'A23456789JQK']for b in'CHSD'],*'JJ'] in 59 bytes. The Haskell solution doesn't need to output to stdout, why would Python? – Enrico Borba Jul 4 at 2:38

Japt, 32 30 bytes


Test it


'J                                 :Literal "J"
  ²                                :Repeat twice
   ¬                               :Split
    c                              :Concatentate
     "JQKA"¬                       :  Split "JQKA"
            c                      :  Concatenate
             9õ                    :    Range [1,9]
               Ä                   :    Add 1 to each
                )                  :  End concatenation
                 £                 :  Map over each element X
                  "CHSD"¬          :    Split "CHSD"
                         m         :    Map
                          iX       :      Prepend X
                            Ã      :  End mapping
                             c     :  Flatten

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.

  • What happens if you make the second argument for STRING_SPLIT an empty string? I don’t use MS-SQL, but in many languages it would give you all the characters in an array. – AJFaraday Jun 12 at 7:15
  • @AJFaraday That would be handy, but it doesn't work, you get Procedure expects parameter 'separator' of type 'nchar(1)/nvarchar(1)'. It would also be handy for golfing if it defaulted to a comma if you left out the second parameter, but it doesn't support that either. Another item for the GolfSQL language I'll probably never get around to writing :) – BradC Jun 12 at 13:29

Ruby, 61 bytes


Try it online!

  • That's some skill to use the J for both Jack and Joker :-) – Marty Neal Jun 14 at 15:37
  • Can't you save 4 bytes by leaving out the ->{...}? It runs on its own and doesn't need parameters, so it shouldn't need to be a lambda – Piccolo Aug 10 at 1:27

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

Try it online.

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()

Try it online.

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.


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

PHP, 108 99 97 Bytes

Try it online!

Try it online! (Edit 1)


<?php $r=[J,J];foreach([A,J,Q,K,2,3,4,5,6,7,8,9,10]as$t)

Tried to use purely php funcions, but bytecount was lower with a loop :(

Output (using print_r)

[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


Thanks to @JoKing by suggesting change explode(" ","H$t S$t D$t C$t") for [H.$t,S.$t,D.$t,C.$t]

  • Wouldn't [H.$t,S.$t,D.$t,C.$t] be shorter than explode? – Jo King Jun 12 at 11:00
  • You are absolutely right, gonna take your advise, thank you. – Francisco Hahn Jun 12 at 13:49
  • 1
    73 bytes: Try it online! – Night2 Jul 22 at 9:56
  • 1
    @FranciscoHahn, sorry, I didn't notice that! Here is a 87 bytes version then: Try it online! – Night2 Jul 23 at 17:09
  • 1
    @Nigth2 i had no idea you can use array_push($arr, $item1,$item2,$item3...$itemN) like that, nice one – Francisco Hahn Jul 23 at 17:13

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')
  • TIO – Erik the Outgolfer Aug 7 at 15:24
  • @EriktheOutgolfer How did you generate that? – mbomb007 Aug 7 at 15:43
  • 1
    I opened the F12 developer tools, selected the text box by hovering, went to the console and, after I copied and pasted the part before the null byte, typed $0.value+='\0'. – Erik the Outgolfer Aug 7 at 16:07

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

J, 41 bytes


Try it online!

  • 1
    'J';^:2,;&.>{_13<\'10';;/'23456789AJKQHCDS' slightly simpler but for 43. I feel like there's more to shave here... but I can't see how. – Jonah Jun 12 at 5:26
  • @Jonah Yes, I also tried something similar and I'm sure my solution can be golfed further, but there are always new problems to be solved :) – Galen Ivanov Jun 12 at 6:27

R, 67 66 bytes


Try it online!

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.

  • oh haha I didn't notice this, I commented this solution on the other one – Giuseppe Jun 11 at 16:48
  • @Giuseppe I was very close to comment instead of posting myself. I guess I just couldn't resist the urge to answer :) – JayCe Jun 11 at 17:35
  • iiiit's just as golfy as digemall's answer :-) try it online – Giuseppe Jun 11 at 17:44
  • @I was just experimenting with that :) so both digemall and I can golf one byte thanks to you :) – JayCe Jun 11 at 17:47

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"}

Try it online!

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

  • 1
    I would argue that c is not a "[...] weird 'function' [...]" but rather an array declaration stored in a macro. Such a form of output is to my knowledge not permitted by default. – Jonathan Frech Jun 11 at 15:19
  • 1
    Except c is not an array, it would be an in-place literal. Each 'invokation' of c in the source will create a new copy of the array in the resulting executable (barring optimizations). Thus, the code char *a[] = c; char *b[] = c; create two deep copies of c. This behaviour is what you'd expect of a function as well. – LambdaBeta Jun 11 at 15:21
  • 1
    If there was a challenge to output the integer zero, would you consider the C code c=0; a valid submission, viewing c as a function? – Jonathan Frech Jun 11 at 15:34
  • 1
    no, but I would consider #define z 0 valid. The reasoning is that: c=0; c++; x=c; results in x == 1 so c doesn't act much like a function. Meanwhile #define z 0 c=z; c++; x=z; does result in x == 0 so z acts like a function. – LambdaBeta Jun 11 at 15:36
  • 1
    I do not think that is a fair comparision as you first change the supposed function, then only change the supposed function's return value. z=0;/**/c=z;c++;x=z; results in x==0, thus z acts like a function. – Jonathan Frech Jun 11 at 15:41

Javascript (ES6) 77 74 72 bytes

This is a complete program.

  • 1
    Nice. You can save a few bytes by splitting on commas instead of concatenating: BTJ,J,${[..."A23456789JQK","10"].map(c=>[..."SDHC"].map(s=>c+s))}BT.splitBT,BT (where BT is a backtick). – Rick Hitchcock Jun 11 at 17:19
  • Awesome suggestion! Thanks. – MattH Jun 11 at 17:20

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

Try it online!

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'

Try it online!

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

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

Perl 6,  43  42 bytes

{|(|(2..10),|<A J Q K>X~ <S D H C>),|<J J>}

Try it

{|(|(^9+2),|<A J Q K>X~ <S D H C>),|<J J>}

Try it from Jo King


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

QBasic 4.5, 114 142 127 bytes

dim r$(54)
FOR i=1TO 52
m=i MOD 13

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$)

[... snip ...]

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
r$(53)="J           ' Then append 2 jokers
r$(54)="J           ' These strings are auto-closed by the QBasic compiler.
  • This does not meet the Array of strings requirement, and printing to STDOUT is explicitly forbidden – Taylor Scott Jun 13 at 15:58
  • @TaylorScott Thanks for noticing. Fixed now, @ 30 bytes extra. – steenbergh Jun 13 at 16:29
  • 1
    I think that you should be able to get the bytecount down by dropping the a$ and b$ vars and using a line something like r$(i)=MID$("JQKA2345678910",1+m,1-(m=12))+MID$("CDHS",(i-1)\13+1,1) – Taylor Scott Jun 13 at 18:31
  • 1
    @TaylorScott Thanks! That reshuffling in the values-string is particularly clever. Nice! – steenbergh Jun 13 at 18:49
  • This is longer than just PRINT "<output>" – Tornado547 Jun 29 at 21:03

Pyth, 26 25 bytes


Saved a byte thanks to hakr14.
Try it here


         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.
  • +\J+\J and +*2]\J are equivalent and both 6 bytes, but the latter is considered better form, as it allows for up to 10 copies to be added before any additional bytes are needed. – hakr14 Jun 13 at 2:05
  • @hakr14 True, but I'm not into code golf for the sake of writing the cleanest or most generalizable code. – Mnemonic Jun 13 at 2:23
  • +\J+\J can be replaced with + B\J to save a byte. – hakr14 Nov 8 at 16:45

Haskell, 57 bytes

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

Try it online!

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.