Consider these 15 ASCII playing card patterns (ace through Joker, and the back side), where X
is a placeholder for the suit symbol: (they look better with less line spacing)
------------- ------------- ------------- ------------- ------------- ------------- ------------- ------------- ------------- ------------- ------------- ------------- ------------- ------------- -------------
|AX | |2X | |3X | |4X | |5X | |6X | |7X | |8X | |9X | |10X | |JX | |QX | |KX | |J | |* * * * * * *|
| ------- | | ------- | | ------- | | ------- | | ------- | | ------- | | ------- | | ------- | | ------- | | ------- | | ------- | | ------- | | ------- | |O ------- | | * * * * * * |
| | | | | | | | | | | | | |X X| | | |X X| | | |X X| | | |X X| | | |X X| | | |X X| | | |X X| | | |X | | | |X | | | |X | | |K | | | |* * * * * * *|
| | | | | | X | | | | X | | | | | | | | | | | | | | | | X | | | | X | | | | | | | | X | | | | | | | | | | | | | | |E | J | | | * * * * * * |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |X X| | | |X X| | | | | | | | | | | | | | |R | O | | |* * * * * * *|
| | X | | | | | | | | X | | | | | | | | X | | | |X X| | | |X X| | | |X X| | | | X | | | | | | | | J | | | | Q | | | | K | | | | K | | | * * * * * * |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |X X| | | |X X| | | | | | | | | | | | | | | | E | J| |* * * * * * *|
| | | | | | X | | | | X | | | | | | | | | | | | | | | | | | | | X | | | | | | | | X | | | | | | | | | | | | | | | | R | O| | * * * * * * |
| | | | | | | | | | | | | |X X| | | |X X| | | |X X| | | |X X| | | |X X| | | |X X| | | |X X| | | | X| | | | X| | | | X| | | | | K| |* * * * * * *|
| ------- | | ------- | | ------- | | ------- | | ------- | | ------- | | ------- | | ------- | | ------- | | ------- | | ------- | | ------- | | ------- | | ------- E| | * * * * * * |
| XA| | X2| | X3| | X4| | X5| | X6| | X7| | X8| | X9| | X10| | XJ| | XQ| | XK| | R| |* * * * * * *|
------------- ------------- ------------- ------------- ------------- ------------- ------------- ------------- ------------- ------------- ------------- ------------- ------------- ------------- -------------
Write a program that takes in a string denoting a space separated sequence of cards using...
A 2 3 4 5 6 7 8 9 10 J Q K
followed by one ofC D H S
(for clubs, diamonds, hearts, and spades) for the 52 standard cards.- A single
R
for a Joker. - A single
B
for the back side (a face down card).
So the string B AS KH 10C R JD
denotes a face down card, followed by an ace of spades, followed by a king of hearts, followed by a ten of clubs, followed by a Joker, followed by a jack of diamonds.
Your program needs to print the corresponding ASCII playing cards to stdout, replacingX
with the appropriate suit symbol.
For example, the output for B AS KH 10C R JD
would be
------------- ------------- ------------- ------------- ------------- -------------
|* * * * * * *| |AS | |KH | |10C | |J | |JD |
| * * * * * * | | ------- | | ------- | | ------- | |O ------- | | ------- |
|* * * * * * *| | | | | | |H | | | |C C| | |K | | | | |D | |
| * * * * * * | | | | | | | | | | | C | | |E | J | | | | | |
|* * * * * * *| | | | | | | | | | |C C| | |R | O | | | | | |
| * * * * * * | | | S | | | | K | | | | | | | | K | | | | J | |
|* * * * * * *| | | | | | | | | | |C C| | | | E | J| | | | |
| * * * * * * | | | | | | | | | | | C | | | | R | O| | | | |
|* * * * * * *| | | | | | | H| | | |C C| | | | | K| | | D| |
| * * * * * * | | ------- | | ------- | | ------- | | ------- E| | ------- |
|* * * * * * *| | SA| | HK| | C10| | R| | DJ|
------------- ------------- ------------- ------------- ------------- -------------
You can take the input from stdin or write a function that takes a string.
The submission with the shortest number of characters wins.
Bonus: Subtract 30 from your character count if you use the black Unicode suit symbols ♣ ♦ ♥ ♠
instead of C D H S
in your output. (The input always uses C D H S
.)
Notes
- There may be more than 54 cards in the input string and there may be duplicates of any card.
- There should be no output if the input is the empty string.
- There should be no trailing spaces besides (optionally) the two that make up the right corners of the last card.
- You may assume the input is valid.
- Update: The lower right label on standard cards has been reversed so the value is in the corner. The lower right Joker label hasn't changed.