32
10
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.
Related – Shaggy – 2018-06-11T08:59:26.807
Are we allowed to print each card to STDOUT instead of returning a list/array? – Kevin Cruijssen – 2018-06-11T09:01:56.147
Can we use
T
instead of10
? – Kevin Cruijssen – 2018-06-11T09:08:12.553@KevinCruijssen no – AJFaraday – 2018-06-11T09:14:00.933
1@AJFaraday No for both my questions? So String list/array and
10
are both mandatory? – Kevin Cruijssen – 2018-06-11T09:15:39.4772@KevinCruijssen that’s correct. The initial question specifies the numbers 2 to 10, and an array of strings as an output. – AJFaraday – 2018-06-11T09:26:57.413
Can we output
C9
instead of9C
? – user41805 – 2018-06-11T10:18:48.540@Cowsquack "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" – AJFaraday – 2018-06-11T10:19:29.787
15I was just wondering if you could get 23456789 by multiplying 2 smaller numbers... only to discover it's prime! – match – 2018-06-11T11:57:28.053
Can we output the two
J
s as characters instead of strings? (Only true for some languages.) Additionally, can we output the other cards as lists of an integer and a character instead of strings? – Erik the Outgolfer – 2018-06-11T12:02:36.020@EriktheOutgolfer I'm afraid it's pretty prescriptive, an array of strings. – AJFaraday – 2018-06-11T12:05:35.017
4@match Since the order of the output doesn't matter, maybe you can still create it with smaller numbers by ending it with
2
or4
or anything else so it isn't a prime anymore. – Kevin Cruijssen – 2018-06-11T13:19:37.090As a poker aficionado, I have to second @KevinCruijssen 's comment of using
T
- it's much, much more common. – corsiKa – 2018-06-11T20:39:46.5902@corsiKa it’s also common to leave the jokers out in poker. Both the numeral 10 and the jokers add a little complexity to the challenge. To change that now would make it an uneven challenge. – AJFaraday – 2018-06-11T20:42:47.083
1@match The product of two positive integers is always smaller than their concatenation. – Dennis – 2018-06-11T21:46:48.137
@match You could do
91**3*35
if your language has a short built-in for cube. – Arnauld – 2018-06-11T23:51:22.9871I dont see the point of disallowing output to stdout. For a lot of languages without structures like functions, arrays or even strings, that's the only way to actually output anything – Jo King – 2018-06-12T01:33:17.170
@JoKing Mostly because in languages which have an array structure, outputting to STDOUT might be shorter than collecting items into an array. – AJFaraday – 2018-06-12T08:17:52.363
I don't think there's anything wrong with having shorter code... – Jo King – 2018-06-12T09:31:55.153
1@JoKing Having shorter code is the goal of code golf. Changing the rules part-way to make the code shorter is utterly un-levelling the playing field. – AJFaraday – 2018-06-12T09:46:49.317
2The playing field isn't very level when you've excluded a majority of languages – Jo King – 2018-06-12T09:55:10.670
1@JoKing For the purposes of this particular challenge, I've made a decision not to modify the rules when there's 20+ responses already. Perhaps raise a meta question about it? – AJFaraday – 2018-06-12T09:56:27.310
5Rules 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 – 2018-06-12T15:05:09.487
@Dennis the spec explicitly states an array of strings. – AJFaraday – 2018-06-12T23:34:09.327
7That 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 – 2018-06-12T23:50:01.243
1What about "Rules of Bridge" in the returned array of strings? :) – billpg – 2018-06-13T15:50:29.763
1@billpg I kind of want to allow that. It wouldn't be fair to make everyone do it now, tho. – AJFaraday – 2018-06-13T15:56:12.567
1Can we use lowercase letters? – Shaggy – 2018-06-18T15:59:57.847