Shuffle Up and Deal!

14

It is Friday and I am tired, so let's do a quick one! Take no input, however you should output all thirteen different numbered cards in a standard deck of cards. You should output 2 through Ace (Suit agnostic).

Each card has a top that is denoted with a space and ten _ and another space .

The second row from the top is denoted with a / and ten spaces and a \

The third row is the same as all the middle-ish rows excepts the character(s) denoting the card value appear two spaces to right (if at the top) or two space to the left (if at the bottom) of the edge.

Each middle-ish row is a simple | and ten spaces and one more |

Finally the last line is a \ and ten _ and finally a /

If the value is multi-digit the overall width by height of the card should not change. (i.e. the 10 will not make the card's sides wider)

King Example:

 __________ 
/          \
| K        |
|          |
|          |
|          |
|          |
|          |
|        K |
\__________/

9 Example

 __________ 
/          \
| 9        |
|          |
|          |
|          |
|          |
|          |
|        9 |
\__________/

10 Example

 __________ 
/          \
| 10       |
|          |
|          |
|          |
|          |
|          |
|       10 |
\__________/

Output them in order from least to greatest (Aces are high!).

This is code-golf so the shortest code wins.

Have fun and have a fun weekend!

jacksonecac

Posted 2016-10-21T19:12:42.413

Reputation: 2 584

2May we have a 10 Example to see if the lower 10 is sticking the right edge or not? – Sunny Pun – 2016-10-21T19:17:21.523

@SunnyPun why of course – jacksonecac – 2016-10-21T19:18:25.347

1Should the cards be arranged vertically, horizontally, or does it matter? – DLosc – 2016-10-21T19:24:34.890

Left to right or top to bottom players choice. – jacksonecac – 2016-10-21T19:25:17.227

Answers

10

PowerShell v2+, 120 116 114 108 bytes

2..10+[char[]]'JQKA'|%{$z=' '*(8-!($_-10));$x='_'*10;$y=' '*10;" $x 
/$y\
| $_$z|";,"|$y|"*5;"|$z$_ |
\$x/"}

Constructs a range 2..10 and does array concatenation with char-array JQKA. Feeds that into a loop |%{...}. Each iteration, we set $z equal to an appropriate number of spaces (based on whether we're at card 10 or not), set $x to 10 underscores, and set $y to 10 spaces.

Then, we begin our placements. We're going to leverage the default Write-Output to insert a newline between pipeline elements, so we just need to get the stuff on the pipeline. Note that in most places, we're using a literal newline rather than closing and reopening our strings to save a couple bytes.

The first is just $x with two spaces, then $y with two slashes, then the | $_$z|" the pipe, a space, the appropriate number of spaces, and another pipe. This forms the top of the cards up to and including the value line.

We have to semicolon here, since the next uses an array. The ,"|$y|"*5 constructs a string-array, with the comma-operator, of the pipe with spaces - on output, each element of this array gets a newline for free.

Then, the "|$z$_ | for the bottom value marking, and finally $x with slashes for the bottom of the card.

Output Snippet

PS C:\Tools\Scripts\golfing> 2..10+[char[]]'JQKA'|%{$z=' '*(8,7)[$_-eq10];" $(($x='_'*10)) ";"/$(($y=' '*10))\";"| $_$z|";,"|$y|"*5;"|$z$_ |";"\$x/"}
 __________ 
/          \
| 2        |
|          |
|          |
|          |
|          |
|          |
|        2 |
\__________/
 __________ 
/          \
| 3        |
|          |
|          |
|          |
|          |
|          |
|        3 |
\__________/
 __________ 
/          \
| 4        |
...

AdmBorkBork

Posted 2016-10-21T19:12:42.413

Reputation: 41 581

1It's a strange day when PowerShell is winning! Nice work :) – Kade – 2016-10-21T20:15:22.010

@Shebang Thanks! Sub-100 is so dang close, but not sure if I can make it. – AdmBorkBork – 2016-10-21T20:27:09.667

[shakes fist] you're beating me by 3 bytes. THREE BYTES!! – Gabriel Benamy – 2016-10-22T00:01:21.270

6

Python, 161 160 156 149 bytes

One byte saved by Shebang

This could use some work but here it is:

o=" ";v="_"*10
for x in map(str,range(2,11)+list("JKQA")):print o+v+"\n/",o*9+"\\\n|",x.ljust(8),"|"+("\n|"+o*10+"|")*5+"\n|",o*6+x.ljust(3)+"|\n\\"+v+"/"

Explanation

We make a list of all the ranks in order using map(str,range(2,11). Then we loop through each of the ranks and make a card.

print o+"_"*10+"\n/",o*9+"\\\n|",x.ljust(8),"|"+("\n|"+o*10+"|")*5+"\n|",o*6+x.ljust(3)+"|\n\\"+"_"*10+"/"

We make the top of the card:

o+v+"\n"

Then the rank goes on the left:

"/",o*9+"\\\n|",x.ljust(8),"|"

We use .ljust because 10 is two long and all the other ones are one wide.

Then we print the 5 rows in the middle:

"|"+("\n|"+o*10+"|")*5+"\n|"

and the bottom rank:

"\n|",o*6+x.ljust(3)+"|\n"

Finally we print the bottom of the card:

"\\"+v+"/"

Post Rock Garf Hunter

Posted 2016-10-21T19:12:42.413

Reputation: 55 382

2Holy Moly that was quick – jacksonecac – 2016-10-21T19:23:34.617

Your byte count seems off (I count 155). However, if you make a variable v="_"*10 and replace those instances will save you another byte! – Kade – 2016-10-21T22:32:36.650

5

JavaScript (ES6), 151 bytes

f=
_=>`2345678910JQKA`.replace(/.0?/g,s=>` __________
/          \\
| `+(s+=`   `+s).slice(0,4)+`     |
|     `.repeat(6)+s.slice(-4)+` |
\\__________/
`)
;
document.write('<pre>'+f());

Neil

Posted 2016-10-21T19:12:42.413

Reputation: 95 035

@Emigna Thanks, I forgot it in my other answer too. – Neil – 2016-10-21T20:10:07.683

4

PHP, 233 Bytes

foreach([2,3,4,5,6,7,8,9,10,J,Q,K,A]as$k){for($c="",$i=0;$i<10;$i++)$c.=str_pad($i?$i>1&$i<9?"|":($i<2?"/":"\\"):" ",11,$i%9?" ":_).($i?$i>1&$i<9?"|":($i<2?"\\":"/"):" ")."\n";$c[113]=$c[28]=$k;$k>9&&$c[29]=$c[113]=0&$c[112]=1;echo$c;}

Jörg Hülsermann

Posted 2016-10-21T19:12:42.413

Reputation: 13 026

1Your last if can be replaced with $k>9&&$c[29]=$c[113]=0&$c[112]=1;, to save a few bytes. Also, Notepad++ is saying your code is actually 241 bytes long. I know 1 of those bytes is from the newline. But the other is a mistery to me. – Ismael Miguel – 2016-10-23T00:06:29.300

4

Perl, 128 117 111 bytes

map{printf$"."_"x10 ."
/".$"x10 .'\
| %-9s|
'.("|".$"x10 ."|
")x5 ."|%9s |
\\"."_"x10 ."/
",$_,$_}2..10,J,Q,K,A

The 6 literal newlines save 1 byte each. This cannot be run directly from the command line because of the single quotes in lines 2 and 4 in order to save 1 byte by not having to escape a backslash.

Edit: I put Ace at the beginning, but it's supposed to be at the end. It doesn't change the byte count.

Edit 2: -11 bytes: Got rid of some unnecessary statements and added another literal newline. Everything is now output via a single printf.

Edit 3: -5 bytes thanks to @Ton Hospel. But for some reason, I'm getting 111 bytes instead of 112 at home when compared to at work, so I'm going with the byte count my home computer is giving me.

Gabriel Benamy

Posted 2016-10-21T19:12:42.413

Reputation: 2 827

You don't have to quote literals that are a valid symbol names, so _ x10 instead of "_"x10. Also qw is almost never useful. in golf. Use unquoted J,Q,K,A instead (even leaving out the ()) – Ton Hospel – 2016-10-21T21:43:25.017

I get an interpreter error when I remove the quotes around the underscore: Can't locate object method "_" via package "x10" (perhaps you forgot to load "x10"?) at shuffle.pl line 1. Not sure why, but I won't fight the interpreter :( – Gabriel Benamy – 2016-10-21T22:21:22.463

1A bit more golfed (replace \n by real newline): printf' %2$s\n/%3$10s\\n| %-9s|\n'.'|%3$10s|\n'x5 .'|%1$9s |\n\%s/\n',$_,"_"x10for 2..10,J,Q,K,A – Ton Hospel – 2016-10-22T09:33:47.537

3

///, 182 180 bytes

/+/_____//*/# |
&//&/@@@@@|# //%/ |
\\\\++\\\/
//$/ ++
\\\/!\\\\
| //#/       //!/#   //@/|!|
/$2*2%$3*3%$4*4%$5*5%$6*6%$7*7%$8*8%$9*9%$10#|
@@@@@|#10 |
\\++\/
$J*J%$K*K%$Q*Q%$A*A%

Try it online!

-2 bytes thanks to m-chrzan

acrolith

Posted 2016-10-21T19:12:42.413

Reputation: 3 728

You can save two bytes by having + substitute for only 5 _s, and then having two +s where you have single +s now. – m-chrzan – 2016-10-21T23:10:20.917

3

Python 3.5, 110 bytes

u='_'*10
for c in[*range(2,11),*'JQKA']:print(' %s\n/%%11s\n'%u%'\\'+'| %-6s%2s |\n'*7%(c,*' '*12,c)+'\%s/'%u)

Prints

  • The top two lines ' %s\n/%%11s\n'%u%'\\' where u is '_'*10
  • The middle 7 lines '| %-2s %2s |\n', each of which has two string formatting slots. The first and last are filled with the card value, and the rest with spaces for no effect
  • The bottom line '\%s/'%u

Python 3.5's new unpacking features are used in two places. The list of labels [*range(2,11),*'JQKA'] unpacks the numbers and letters into one list. And, the tuple (c,*' '*12,c) unpacks twelve entries of spaces into the center.

xnor

Posted 2016-10-21T19:12:42.413

Reputation: 115 687

2

Batch, 236 bytes

@echo off
for %%v in (2 3 4 5 6 7 8 9 10 J Q K A)do call:v %%v
exit/b
:v
set s=%1       %1
echo  __________
echo /          \
echo ^| %s:~0,8% ^|
for /l %%l in (1,1,5)do echo ^|          ^|
echo ^| %s:~-8% ^|
echo \__________/

I tried golfing this in three different ways but ended up with the same byte count each time...

Neil

Posted 2016-10-21T19:12:42.413

Reputation: 95 035

2

Scala, 161 bytes

val a=" "*7
val u="_"*10
((2 to 10)++"JQKA")map(_+"")map{x=>val p=" "*(2-x.size)
s" $u \n/$a   \\\n| $x$p$a|\n" + s"|$a   |\n" * 5 + s"|$a$p$x |\n\\$u/\n"}

corvus_192

Posted 2016-10-21T19:12:42.413

Reputation: 1 889

2

05AB1E, 71 70 68 66 65 64 bytes

Uses CP-1252 encoding.

TL¦"JQKA"S«vð'_TשððT×…/ÿ\9yg-ð×y"| ÿÿ|"ÂðT×…|ÿ|5×sT‡®…\ÿ/JTä»,

Slightly modified link as doesn't work with ÿ on TIO atm.

Try it online!

Explanation

TL¦"JQKA"S« pushes the list [2,3,4,5,6,7,8,9,10,J,Q,K,A]

We then loop over each card value with v

ð'_Tשð constructs " __________ "
ðT×…/ÿ\ constructs "/ \"
9yg-ð×y"| ÿÿ|"Â constructs the 2 rows with card values (the second row is the first reversed)
ðT×…|ÿ|5× constructs 5 rows of the form "| |"

Then we

s     # move the 2nd card value row after the 5 "middle rows"
 T‡  # and replace 1 with 0 and vice versa

®…\ÿ/ constructs the bottom row

J       # join everything into 1 string
 Tä     # split into 10 parts
   »,   # merge by newline and print with newline

Emigna

Posted 2016-10-21T19:12:42.413

Reputation: 50 798

2

V, 87 bytes

i ±_ 
/± \Ypr|$.Y6P3|r2Lhhr2o\±_/
H8ñy}GP2j6j? _ñ2j$X6jxG"04p/9
rJn.nrQn,nrKn.nrAn.

Try it online!

Since this contains some unprintables, here is a hexdump:

0000000: 6920 b15f 200a 2fb1 205c 1b59 7072 7c24  i ._ ./. \.Ypr|$
0000010: 2e59 3650 337c 7232 4c68 6872 326f 5cb1  .Y6P3|r2Lhhr2o\.
0000020: 5f2f 0a1b 4838 f179 7d47 5032 6a01 366a  _/..H8.y}GP2j.6j
0000030: 013f 205f f132 6a24 5836 6a78 4722 3034  .? _.2j$X6jxG"04
0000040: 702f 390a 724a 6e2e 6e72 516e 2c6e 724b  p/9.rJn.nrQn,nrK
0000050: 6e2e 6e72 416e 2e                        n.nrAn.

James

Posted 2016-10-21T19:12:42.413

Reputation: 54 537

2

PHP, 135 131 158 134 bytes

Hopefully, I can find a way to shorten this a little more.

foreach([2,3,4,5,6,7,8,9,10,J,Q,K,A]as$C)printf(" %'_9s
/%12s| %-8s|%s
|%8s |
\\%'_9s/
",_,'\
',$C,str_repeat('
|         |',5),$C,_);

This takes advantage of printf to repeat multiple characters and format everything nicely.


Old version:

Not exactly a piece of beauty, but works!

$L=__________;$S='        ';foreach([2,3,4,5,6,7,8,9,10,J,Q,K,A]as$C)echo" $L
/  $S\
| $C".($P=substr($S,$C>9))."|
",str_repeat("|  $S|
",5),"|$P$C |
\\$L/
";

Thanks to Jörg Hülsermann for detecting a bug and for letting me use part of his code, that reduced it by 4 bytes! And for finding a fatal bug.

Ismael Miguel

Posted 2016-10-21T19:12:42.413

Reputation: 6 797

The 10 looks strange. I believe you must do extra work – Jörg Hülsermann – 2016-10-22T22:36:18.807

@JörgHülsermann You're right. The 10 is bugged. Is it alright if I use your array? Using [2,3,4,5,6,7,8,9,10,J,Q,K,A] instead of that split saves me 4 bytes. If you don't authorize it, I will understand. – Ismael Miguel – 2016-10-22T22:45:40.650

Take it. You have make the better way in PHP and I support all what you need. – Jörg Hülsermann – 2016-10-22T22:54:27.613

@JörgHülsermann Thank you. I am looking at your answer and I'm finding some places where to shave off some bytes. – Ismael Miguel – 2016-10-22T23:38:20.597

Instead of $C$S $C".($P=substr($S,$C>9))." to handle the spaces with value 10 and instead of $S$C you need then $P$C – Jörg Hülsermann – 2016-10-23T00:34:00.697

@JörgHülsermann I'm sorry, but I don't understand :/ – Ismael Miguel – 2016-10-23T00:36:02.900

If you have value 10 you have one space more then you need | 9 | in comparision to | 10 | and so you must short the space sequence – Jörg Hülsermann – 2016-10-23T00:39:18.367

@JörgHülsermann Should be fixed now. Thanks for finding it. – Ismael Miguel – 2016-10-23T00:50:43.330

1

Ruby, 115 bytes

Fairly straightforward use of printf.

([*(?2.."10")]+%w{J Q K A}).map{|e|printf" #{u=?_*10} 
/%11s
| %-9s|
#{(?|+' '*10+"|
")*5}|%9s |
\\#{u}/
",?\\,e,e}

Level River St

Posted 2016-10-21T19:12:42.413

Reputation: 22 049

1

Racket 327 bytes

(let*((ms make-string)(p #\space)(e? equal?)(sa string-append)(f(λ(s)(display(sa" "(ms 10 #\_)" \n""/"(ms 10 p)"\\\n""| "s
(ms(if(e? s"10")7 8)p)"|\n"(apply sa(for/list((i 6))"|          |\n"))"| "(ms(if(e? s"10")6 7)p)s" |\n"
"\\"(ms 10 #\_)"/\n")))))(for((i(range 2 11)))(f(number->string i)))(for((i'("J""Q""K""A")))(f i)))

Ungolfed:

(define (main)
(let* ((ms make-string)
       (e? equal?)
       (sa string-append)
      (f(lambda(s)
  (display
   (sa
    " "
    (ms 10 #\_)
    " \n"
    "/"
    (ms 10 #\space)
    "\\\n"
    "| " s   (ms (if(e? s "10") 7 8) #\space)   "|\n"
    (apply sa (for/list ((i 6)) "|          |\n"))
    "| "  (ms (if(e? s "10") 6 7) #\space)  s " |\n"
    "\\" (ms 10 #\_) "/\n")
   ))))
(for ((i(range 2 11)))
  (f (number->string i)))
(for ((i '("J" "Q" "K" "A")))
  (f i))
))

Testing:

(main)

Output:

 __________ 
/          \
| 2        |
|          |
|          |
|          |
|          |
|          |
|          |
|        2 |
\__________/
 __________ 
/          \
| 3        |
|          |
|          |
|          |
|          |
|          |
|          |
|        3 |
\__________/
 __________ 
/          \
| 4        |
|          |
|          |
|          |
|          |
|          |
|          |
|        4 |
\__________/
 __________ 
/          \
| 5        |
|          |
|          |
|          |
|          |
|          |
|          |
|        5 |
\__________/
 __________ 
/          \
| 6        |
|          |
|          |
|          |
|          |
|          |
|          |
|        6 |
\__________/
 __________ 
/          \
| 7        |
|          |
|          |
|          |
|          |
|          |
|          |
|        7 |
\__________/
 __________ 
/          \
| 8        |
|          |
|          |
|          |
|          |
|          |
|          |
|        8 |
\__________/
 __________ 
/          \
| 9        |
|          |
|          |
|          |
|          |
|          |
|          |
|        9 |
\__________/
 __________ 
/          \
| 10       |
|          |
|          |
|          |
|          |
|          |
|          |
|       10 |
\__________/
 __________ 
/          \
| J        |
|          |
|          |
|          |
|          |
|          |
|          |
|        J |
\__________/
 __________ 
/          \
| Q        |
|          |
|          |
|          |
|          |
|          |
|          |
|        Q |
\__________/
 __________ 
/          \
| K        |
|          |
|          |
|          |
|          |
|          |
|          |
|        K |
\__________/
 __________ 
/          \
| A        |
|          |
|          |
|          |
|          |
|          |
|          |
|        A |
\__________/

rnso

Posted 2016-10-21T19:12:42.413

Reputation: 1 635

1

Java 7, 287 bytes

String c(){String r="",l="__________",c=(" "+l+" \n/s\\\n| z       |\nxxxxxx|       y|\n\\"+l+"/\n").replace("x","|s|\n").replace("s","          ");for(int i=0;i++<13;r+=c.replace("z",i==10?"10":(l=i<2?"A ":i>12?"K ":i>11?"Q ":i>10?"J ":i+" ")).replace("y",i==10?"10 ":" "+l));return r;}

Ok, this is ugly and not very efficient, but it works.. That 10 as special case with a space before at the top and after at the bottom position really screws with everyone..

Ungolfed & test code:

Try it here.

class M{
  static String c(){
    String r = "",
           l = "__________",
           c = (" " + l + " \n/s\\\n| z       |\nxxxxxx|       y|\n\\" + l + "/\n")
                 .replace("x", "|s|\n")
                 .replace("s", "          ");
    for(int i = 0; i++ < 13; r += c
        .replace("z", i == 10
                       ? "10"
                       : (l = i < 2
                               ? "A "
                               : i > 12
                                  ? "K "
                                  : i > 11
                                     ? "Q "
                                     : i > 10
                                        ? "J "
                                        : i+" "))
        .replace("y", i == 10
                       ? "10 "
                       : " "+l));
    return r;
  }

  public static void main(String[] a){
    System.out.println(c());
  }
}

Output:

 __________ 
/          \
| A        |
|          |
|          |
|          |
|          |
|          |
|          |
|        A |
\__________/
 __________ 
/          \
| 2        |
|          |
|          |
|          |
|          |
|          |
|          |
|        2 |
\__________/
 __________ 
/          \
| 3        |
|          |
|          |
|          |
|          |
|          |
|          |
|        3 |
\__________/
 __________ 
/          \
| 4        |
|          |
|          |
|          |
|          |
|          |
|          |
|        4 |
\__________/
 __________ 
/          \
| 5        |
|          |
|          |
|          |
|          |
|          |
|          |
|        5 |
\__________/
 __________ 
/          \
| 6        |
|          |
|          |
|          |
|          |
|          |
|          |
|        6 |
\__________/
 __________ 
/          \
| 7        |
|          |
|          |
|          |
|          |
|          |
|          |
|        7 |
\__________/
 __________ 
/          \
| 8        |
|          |
|          |
|          |
|          |
|          |
|          |
|        8 |
\__________/
 __________ 
/          \
| 9        |
|          |
|          |
|          |
|          |
|          |
|          |
|        9 |
\__________/
 __________ 
/          \
| 10       |
|          |
|          |
|          |
|          |
|          |
|          |
|       10 |
\__________/
 __________ 
/          \
| J        |
|          |
|          |
|          |
|          |
|          |
|          |
|        J |
\__________/
 __________ 
/          \
| Q        |
|          |
|          |
|          |
|          |
|          |
|          |
|        Q |
\__________/
 __________ 
/          \
| K        |
|          |
|          |
|          |
|          |
|          |
|          |
|        K |
\__________/

Kevin Cruijssen

Posted 2016-10-21T19:12:42.413

Reputation: 67 575

1

R, 175 bytes

for(x in c(2:10,"J","Q","K","A")){r=c("|"," ",x,rep(" ",9-nchar(x)),"|");cat(" __________ \n/          \\\n",r,"\n",rep("|          |\n",5),rev(r),"\n\\__________/\n",sep="")}

A fairly competitive answer in R this time for an ascii-art challenge and should definitely be golfable.

Try it on R-fiddle

Ungolfed and explained

for(x in c(2:10,"J","Q","K","A")){          # For each card in vector 1,...,10,J,Q,K,A
    r=c("|"," ",x,rep(" ",9-nchar(x)),"|")  # Create variable for 3rd row called "r".
    ;cat(" __________ \n/          \\\n",   # Print: hardcoded top two rows,
    r,"\n",                                 # 3rd row,
    rep("|          |\n",5),                # Repeat middle section 5 times,
    rev(r),                                 # Reversed 3rd row,
    "\n\\__________/\n",                    # Hardcoded bottom row
    sep="")                                 # Set separator to empty string
}

The most interesting aspect where a few bytes are saved is the assignment of the third row:

r=c("|"," ",x,rep(" ",9-nchar(x)),"|")

Because there are 8 spaces in total between the character denoting the card value and the final | (except for 10) we can repeat 9 spaces and subtract the number of characters in the currently printed card.

By storing each character in the 3rd row as its own element in the string vector r we can reverse the vector and reuse it for the 9th row.

Billywob

Posted 2016-10-21T19:12:42.413

Reputation: 3 363

1

C#, 385 Bytes

My first ASCII Art challenge - it was fun!

Golfed:

string D(){var d=new string[15];for(int i=2;i<15;i++){var a=i>10?new Dictionary<int,string>(){{ 11,"J"},{12,"Q"},{13,"K"},{14,"A"},}[i]:i+"";var r="|          |";d[i]=string.Join("\n",new string[]{" __________",@"/          \",a.Length>1?"| "+a+"       |":"| "+a+"        |",r,r,r,r,r,a.Length>1?"|       " + a +" |" : "|        "+a+" |",@"\__________/"});}return string.Join("\n",d);}

Ungolfed:

public string D()
{
  var d = new string[15];

  for (int i = 2; i < 15; i++)
  {
    var a = i > 10 ? new Dictionary<int, string>() {
    { 11, "J" },
    { 12, "Q" },
    { 13, "K" },
    { 14, "A" },
    }[i] 
      : i+"";

    var r = "|          |";

    d[i] = string.Join("\n", new string[] {
      " __________",
      @"/          \",
      a.Length > 1 ? "| " + a + "       |" : "| " + a + "        |",
      r,
      r,
      r,
      r,
      r,
      a.Length > 1 ? "|       " + a +" |" : "|        " + a +" |",
      @"\__________/"});
  }

  return string.Join("\n", d);
}

Pete Arden

Posted 2016-10-21T19:12:42.413

Reputation: 1 151

1

Actually, 91 bytes

"JQKA"#9⌐2x+`;k' ;'_9u*@++'\' 9u*'/++"| {:<9}|"5'|;' 9u*@++n"|{:>9} |"'/'_9u*'\++kp@'
jf`Mi

Try it online!

Explanation

Part 1: setting up the list of face values:

"JQKA"#9⌐2x+`PART 2 CODE`Mi
       9⌐2x                  range(2,11) ([2, 10])
"JQKA"#    +                 extend with ["J", "Q", "K", "A"]
            `PART 2 CODE`M   do Part 2 for each item in list
                          i  flatten resulting list and implicitly print

Part 2: creating the cards (newline replaced with \n for readability):

;k' ;'_9u*@++'\' 9u*'/++"| {:<9}|"5'|;' 9u*@++n"|{:>9} |"'/'_9u*'\++kp@'\njf
;k                                                                            duplicate the face value, push both copies to a list
  ' ;'_9u*@++                                                                 construct the top line
             '\' 9u*'/++                                                      construct the second line
                        "| {:<9}|"                                            create a format string to place the value in a left-aligned 9-width field in the top left of the card, one space away from the edge
                                  5'|;' 9u*@++n                               create 5 copies of the blank middle section
                                               "|{:>9} |"                     like before, but right-align the face value
                                                         '/'_9u*'/++          construct the bottom of the card
                                                                    kp@'\nj   push entire stack to a list, pop the list containing the face values out of that list, and join the rest (the card strings) with newlines
                                                                           f  format the card with the face values

Mego

Posted 2016-10-21T19:12:42.413

Reputation: 32 998