19
3
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.
1Can we assume the input string is valid ? – Michael M. – 2014-09-29T08:17:15.190
Should the lower-right Joker be upside down? – VisualMelon – 2014-09-29T08:17:20.763
1@VisualMelon I tried that but it looks funny. It will stay upright. – Calvin's Hobbies – 2014-09-29T08:22:58.320
May I suggest a -20 score if someone prints the lower right label (be it
JOKER
orNX
) using the upside down symbols equivalent to the English alphabets. Example :S∀
,ᴚƎʞOſ
etc. – Optimizer – 2014-09-29T08:26:40.7203
@Optimizer I would do that if there were designated upsidedown characters for what I need but I don't think there are and I don't want it all wonky.
– Calvin's Hobbies – 2014-09-29T08:31:46.870Should the lower-right 10X be X01, rather than X10? This is what I would figure from the pictures on Wikipedia – VisualMelon – 2014-09-29T09:13:23.927
2@VisualMelon I know that realistically half of the labels would be upside down, but since there aren't upside down characters for that I'm ignoring that fact (besides that I wanted the values in the corner). – Calvin's Hobbies – 2014-09-29T09:18:21.627
1If you're only going to subtract 10 points for properly Unicoding the symbols, it's never going to be worth it because you need more than that just to write them (6 characters per symbol, 24 overall). Even if you got a unicode-compliant language, the unicode symbols are in the reverse order from your input when alphabetical. I think only something like CJAM, APL or Golfscript would be able to do that. – Nzall – 2014-09-29T13:48:40.137
@NateKerkhofs Good points. The bonus has been changed from 10 to 30. – Calvin's Hobbies – 2014-09-29T21:25:49.147