#C# .NET, 114 bytes
C# .NET, 114 bytes
o=>(new System.Text.RegularExpressions.Regex("1?.").Replace("AJQK2345678910","$0H,$0S,$0D,$0C,")+"J,J").Split(',')
Port of my Java answer (credit to @mazzy).
Interesting alternative of 119 bytes by @Corak.
using System.Linq;o=>new[]{"J","J"}.Concat(from s in"SDCH"from n in"A234567890JQK"select(n=='0'?"10":n+"")+s).ToArray()
If an System.Collections.Generic.IEnumerable<string>
instead of string[]
is an acceptable output, the trailing .ToArray()
can be dropped so it becomes 109 bytes.
Explanation:
using System.Linq; // Required import for the `from .. in ..` and `select` parts
o=> // Method with empty unused parameter and string-array return-type
new[]{"J","J"} // Return a string-array containing two times "J"
.Concat( // And add:
from s in"SDCH" // Loop over the suits
from n in"A234567890JQK"
// Inner loop over the cards
select(n=='0'? // If the current card item is '0'
"10" // Use 10 instead
: // Else:
n+"") // Simply use the card item as is
+s)// And append the suit
.ToArray() // Convert the IEnumerable to an array