20
2
A casino uses the following deck of cards. (*
is one of the card suits D
, S
, C
or H
.)
_________ _________ _________ _________ _________
| | | | | | | | | |
| | | | | * | | * * | | * * |
| | | * | | | | | | |
| * | | | | * | | | | * |
| | | * | | | | | | |
| | | | | * | | * * | | * * |
|_________| |_________| |_________| |_________| |_________|
_________ _________ _________ _________ _________
| | | | | | | | | |
| * * | | * * | | * * | | * * | | * * |
| | | | | * * | | * * | | * * |
| * * | | * * * | | | | * | | * * |
| | | | | * * | | * * | | * * |
| * * | | * * | | * * | | * * | | * * |
|_________| |_________| |_________| |_________| |_________|
_________ _________ _________
| | | | | |
| * * | | * * | | * * * |
| * * | | * * * | | * * |
| * * * | | * * | | * * * |
| * * | | * * * | | * * |
| * * | | * * | | * * * |
|_________| |_________| |_________|
After each night, old decks are discarded, and cut in half to avoid reuse. As a result, the casino has a big room full of cut card halves.
Unfortunately the economy is bad, and the casino is in financial trouble. The most reasonable thing to save money seems to be recycling, so the casino owners decide to tape old cards back together. So they hire a team to build a machine which will do this.
You are part of the team, and your job is to help identifying the card.
Write a program or function which will take an ASCII art image of a card half in the form of a string, and will return a string of what card it is.
Input is an 11x5 string, plus line break characters (CR, LF or CRLF, you only need to support one). You may assume trailing whitespace at the end of each input line, if necessary. The input won't contain any invalid characters (any other than _|-HSCD
and space and line break).
A card half will look like this:
_________
| |
| H H |
| H H H |
---H---H---
which should be identified as the Queen of Hearts:
H12
The casino is on a limited budget, so this is code golf: the shortest program wins.
@Optimizer Well, we all know casinos are poor underdogs of society :) I added some clarification on input. – user694733 – 2015-05-07T13:34:40.807
what methods of input are acceptable? – tfitzger – 2015-05-07T13:42:11.470
@tfitzger Any kind of string or character array that represents the card. I don't want to put too strict restrictions on that, as it's not "the meat" of the puzzle. – user694733 – 2015-05-07T13:44:42.250
Thanks. Also, what about inputs that don't match a card above. For example,
_________\n| |\n| H H |\n| H H H |\n-------H---
. – tfitzger – 2015-05-07T13:57:21.0932@tfitzger You can ignore any invalid/impossible cards. We assume that there are only valid cards. So you need to only take previously mentioned 13 layouts in to consideration. – user694733 – 2015-05-07T14:00:17.553
2Can the output have a space between the two? Like
H 12
? – mbomb007 – 2015-05-07T18:41:41.820What does budget have to do with the number of lines of code? :) – DA. – 2015-05-07T21:27:30.413
@DA. Maybe the programmers are paid by the line/byte... – mbomb007 – 2015-05-07T21:28:59.340
1@DA we forgot to mention they casino managers are stuck with 1980's business practices. – corsiKa – 2015-05-08T16:49:11.477