Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

Generate a deck of cards

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.

Answer*

Draft saved
Draft discarded
Cancel
4
  • \$\begingroup\$ Hint: you can use a single printf to get rid of all putchars. \$\endgroup\$ Commented Jun 11, 2018 at 21:57
  • 1
    \$\begingroup\$ 127 bytes. \$\endgroup\$ Commented Jun 11, 2018 at 22:00
  • 1
    \$\begingroup\$ Regarding your method of output, the OP does not allow printing. \$\endgroup\$ Commented Jun 11, 2018 at 22:03
  • \$\begingroup\$ Building on Jonathan Frech and Dennis 113 bytes \$\endgroup\$ Commented Aug 5, 2019 at 5:04

AltStyle によって変換されたページ (->オリジナル) /