text:
Count the timespans
Inspired by a real-life scenario, which I have asked for an answer to here: https://superuser.com/questions/1312212/writing-a-formula-to-count-how-many-times-each-date-appears-in-a-set-of-date-ran
Given an array of timespans (or startdate-enddate pairs), output a count of how many timespans cover each day, for all days in the total range.
For example:
  #      Start      End
  1    2001-01-01 2001-01-01
  2    2001-01-01 2001-01-03
  3    2001-01-01 2001-01-02
  4    2001-01-03 2001-01-03
  5    2001-01-05 2001-01-05

Given the above data, the results should be as follows:
2001-01-01: 3 (Records 1,2,3)
2001-01-02: 2 (Records 2,3)
2001-01-03: 2 (Records 2,4)
2001-01-04: 0
2001-01-05: 1 (Record 5)

You only need to output the counts for each day (in order, sorted oldest-newest); not which records they appear in.
You can assume that each timespan only contains dates, not times; and so whole days are always represented.
I/O
Input can be any format that represents a set of timespans - so either a set of pairs of times, or a collection of (builtin) objects containing start- and end-dates. The date-times are limited to between 1901 and 2099, as is normal for PPCG challenges.
You can assume the input is pre-sorted however you like (specify in your answer). Input dates are inclusive (so the range includes the whole of the start and end dates).
You can also assume that, of the two dates in any given range, the first will be older or equal to the second (i.e. you won't have a negative date range).
Output is an array containing the count for each day, from the oldest to the newest in the input when sorted by Start Date.
So, the output for the above example would be {3,2,2,0,1}
It is possible that some days are not included in any time range, in which case 0 is output for that date.
Winning Criteria
This is code-golf, so lowest bytes wins. Usual exclusions apply
Pseudo-algorithm example
For each time range in input
    If start is older than current oldest, update current oldest
    If end is newer than current newest, update current newest
End For
For each day in range oldest..newest
   For each time range
       If timerange contains day
            add 1 to count for day
End For
Output count array

Other algorithms to get to the same result are fine.

Is an array of integers required, or are we allowed to return something else, say a dictionary with keys as each date? If we are allowed to return a dictionary, then can we omit dates that are not in any of the timespans?

can we take input as two lists, one with start dates and the other with corresponding end dates?

Yeah, all of those things are fine, except omitting a date - I explicitly say that 0 should be output in that case

May I ask why 0 should be in a dictionary? It only appears to force the user to iterate from min(input) to max(input), which doesn't seem to add anything to the core of the challenge (computing timespans).

Has this been in the Sandbox for quite a while (more than a few months)? I could have sworn I've seen a similar challenge before, but am unable to find it..

Yeah, it's been there a while - I only just got around to moving it here as it had a few upvotes so I thought it worthwhile

@JungHwanMin I guess it doesn't alter it; but because I explicitly had it in the spec when I posted it, I don't want to go messing with it and make someone else redo their answer

@simonalexander2005 Making 0 optional wouldn't invalidate anything.

@JungHwanMin making 0 optional could make some valid answer longer than necessary

@edc65 How so? They could include the 0 if the version that has the 0 is shorter.

@JungHwanMin now the 0s are not optional. There are now valid answers that could be made shorter if 0 is optional. So people should modify their now valid answer to comply with the new spec, or leave a sub optimal answer.

If returning a dictionary/object, does it need to be sorted by date or is it enough that the keys indicate with date is which?

Suggested test case: 2000-02-27 2000-03-02

@Jakob correct, added.

@Shaggy no sort needed

APL (Dyalog Unicode), 32 bytesSBCS
Full program. Prompts stdin for a list of pairs of International Date Numbers (like what Excel and MATLAB use). Both list and pairs may be given in any order, e.g. (End,Start). Prints list of counts to stdout.
¯1+⊢∘≢⌸(R,⊢)∊(R←⌊/,⌊/+∘⍳⌈/-⌊/)¨⎕ Try it online!
If this is invalid, a list of (Y M D) pairs can be converted for an additional 21 bytes, totalling 53:
¯1+⊢∘≢⌸(R,⊢)∊(R⌊/,⌊/+∘⍳⌈/-⌊/)¨{2⎕NQ#'DateToIDN'⍵}¨¨⎕ Try it online!

⎕ prompt console for evaluated input
(…)¨ apply the following tacit function to each pair
⌊/ the minimum (lit. min-reduction), i.e. the start date
⌈/- the maximum (i.e. end date) minus that
⌊/+∘⍳ the start date plus the range 1-through-that
⌊/, the start date prepended to that
R← assign this function to R (for Range)
∊ ϵnlist (flatten) the list of ranges into a single list
(…) apply the following tacit function to that:
 R,⊢ the result of applying R (i.e. the date range) followed by the argument
  (this ensures that each date in the range is represented at least once, and that the dates appear in sorted order)
…⌸ for each pair of unique (date, its indices of occurrence in the input), do:
 ⊢∘≢ ignore the actual date in favour of the tally of indices
¯1+ add -1 to those tallies (because we prepended one of each date in the range)

JavaScript (ES6), 85 bytes
Takes input as a list of Date pairs. Expects the list to be sorted by starting date. Returns an array of integers.
f=(a,d=+a[0][0])=>[a.map(([a,b])=>n+=!(r|=d<b,d<a|d>b),r=n=0)|n,...r?f(a,d+864e5):[]]

Try it online!
or 84 bytes if we can take JS timestamps as input (as suggested by @Shaggy)

Ah, nuts!

Save a byte by taking the primitive values as input: TIO

JavaScript, 75 73 bytes
Takes input as a sorted array of arrays of date primitive pairs, outputs an object where the keys are the primitives of each date and the values the counts of those dates in the ranges.
a=>a.map(g=([x,y])=>y<a[0][0]||g([x,y-864e5],o[y]=~~o[y]+(x<=y)),o={})&&o

Try it

I was working on this 60 byte version until it was confirmed that dates that don't appear in any of the ranges must be included so hastily updated it to the solution above.
a=>a.map(g=([x,y])=>x>y||g([x+864e5,y],o[x]=-~o[x]),o={})&&o

Try it online (or with human readable dates in the output)

It looks like ES6 does define a key order for JS objects (https://stackoverflow.com/a/31102605/8127), basicaly insertion order for string and symbol keys (and TIO's Nodejs does seem to follow that: https://tinyurl.com/ybjqtd89). And in general my opinion is that an implementation detail (which is what the object here is) shouldn't dictate the interpretation of the challenge rules, but I'll wait for the Meta post.

Octave, 63 bytes
@(x)histc(t=[cellfun(@(c)c(1):c(2),x,'un',0){:}],min(t):max(t))

Try it online!
Now that was ugly!
Explanation:
Takes the input as a cell array of datenum elements (i.e. a string "2001-01-01" converted to a numeric value, looking like this:
{[d("2001-01-01") d("2001-01-01")]
[d("2001-01-01") d("2001-01-03")]
[d("2001-01-01") d("2001-01-02")]
[d("2001-01-03") d("2001-01-03")]
[d("2001-01-05") d("2001-01-05")]};

where d() is the function datenum. We then use cellfun to create cells with the ranges from the first column to the second for each of those rows. We concatenate these ranges horizontally, so that we have a long horizontal vector with all the dates.
We then create a histogram using histc of these values, with bins given by the range between the lowest and the highest date.

R, 75 bytes
function(x,u=min(x):max(x))rowSums(outer(u,x[,1],">=")&outer(u,x[,2],"<="))

Try it online!
Input is a matrix whose first column is Start and second column is End. Assumes Start<=End but does not require Start dates to be sorted.

This is as far as i was able to go trying to replicate the Octave answer by Stewie Griffin... what am I doing wrong?

it's because of the way R does its bins in hist; you could do c(-25668,min(x):max(x)) since -25568 is before 1900 but this ends up being longer than your suggested answer. That being said, there's a better way to generate the dates than apply; I have one that's at 68 bytes and I just haven't found the time to post it myself.

Ah, no, actually, use (min(x)-1):max(x) and it should work as expected; then if you can find the not-apply way to generate the dates you can get this to 63 bytes and tie the Octave answer.

@Giuseppe You should post it as a separate answer :)

posted :-) I have to admit, I was using table and factor before which was my original use of Map for 68 bytes, but hist is a neat approach that I always forget about, probably because it's annoying to get the bins just right (as we have seen)

@Giuseppe very clever use of Map. I don’t think I have ever used it for golfing.

Python 2, 114 87 93 bytes
-27 bytes thanks to Jonathan Allan
+6 bytes thanks to sundar
Takes input as list of pairs of datetime objects.
Assumes that first pair starts with the lowest date.
def F(I):
 d=I[0][0]
 while d<=max(sum(I,[])):print sum(a<=d<=b for a,b in I);d+=type(d-d)(1)

Try it online!

days is the default argument for timedelta.

...in fact I think you can drop the from datetime import* and replace d+=timedelta(days=1) with d+=type(d-d)(1) since the inputs are already dates. 87 bytes

This seems to assume that the start of the first range is the lowest date AND the end of the last range is the highest - but I think that's sometimes not possible even if the OP allows us to take sorted input. For eg. if input is [(2001-01-01, 2001-01-05), (2001-01-02, 2001-01-03)]. Unless OP allows us to split and rearrange these ranges during preprocessing (which seems unlikely), this input can't be processed by this code properly.

@sundar Yes, I see what you're talking about. I've updated solution to handle this. Thanks!

Groovy, 142 bytes
{a={Date.parse('yyyy-mm-dd',it)};b=it.collect{a(it[0])..a(it[1])};b.collect{c->b.collect{it}.flatten().unique().collect{it in c?1:0}.sum()}}

Formatted out:
 {                                   // Begin Closure
    a={Date.parse('yyyy-mm-dd',it)}; // Create closure for parsing dates, store in a().
    b=it.collect{                    // For each input date pair...
        a(it[0])..a(it[1])           // Parse and create date-range.
    };
    b.collect{                       // For each date range...
        c->
        b.collect{                   // For each individual date for that range...
           it
        }.flatten().unique().collect{ // Collect unique dates.
            it in c?1:0
        }.sum()                      // Occurrence count.
    }
}

Red, 174 bytes
func[b][m: copy #()foreach[s e]b[c: s
until[m/(c): either none = v: m/(c)[1][v + 1]e < c: c + 1]]c: first sort b
until[print[either none = v: m/(c)[0][v]](last b)< c: c + 1]]

Quite long and literal implementation.
Try it online!
Readable:
f: func [ b ] [
    m: copy #()
    foreach [ s e ] b [
        c: s
        until [
            m/(c): either none = v: m/(c) [ 1 ] [ v + 1 ]
            e < c: c + 1
        ]
    ]
    c: first sort b
    until[
        print [ either none = v: m/(c) [ 0 ] [ v ] ]
        ( last b ) < c: c + 1
    ]
]

R, 65 63 bytes
function(x)hist(unlist(Map(`:`,x[,1],x[,2])),min(x-1):max(x))$c

Try it online!
This is a collaboration between JayCe and myself, porting Stewie Griffin's answer over to R.
To quote JayCe:

Input is a matrix whose first column is Start and second column is End. Assumes Start<=End but does not require Start dates to be sorted.

Possibly, $c is unnecessary but it's not quite in the spirit of the challenge so I've included it.

Min(x-1) for 2 bytes ?

^ By which I mean this

@JayCe yes, nice! I meant to come back to this earlier but I forgot.

Wolfram Language (Mathematica), 62 bytes
Lookup[d=DayRange;Counts[Join@@d@@@#],#[[1,1]]~d~#[[-1,1]],0]&

Try it online!
+35 bytes because OP specified that 0 must be included in the output.
If omitting an entry in a dictionary were allowed, 27 bytes
Counts[Join@@DayRange@@@#]&

Try it online!
The built-in DayRange accepts two DateObjects (or a string equivalent) and outputs a list of Dates between those dates (inclusive).

Powershell, 122 121 118 113 bytes
filter d{0..($_[-1]-($s=$_[0])).Days|%{$s.AddDays($_)}}$c=@{};$args|d|%{++$c.$_};,($c.Keys.Date|sort)|d|%{+$c.$_}

save it as count-timespan.ps1. Test script:
.\count-timespan.ps1 `
    @([datetime]"2001-01-01", [datetime]"2001-01-01")`
    @([datetime]"2001-01-01", [datetime]"2001-01-03")`
    @([datetime]"2001-01-01", [datetime]"2001-01-02")`
    @([datetime]"2001-01-03", [datetime]"2001-01-03")`
    @([datetime]"2001-01-05", [datetime]"2001-01-05")

Explanation
filter d{                           # define a function with a pipe argument (it's expected that argument is an array of dates)
    0..($_[-1]-($s=$_[0])).Days|%{  # for each integer from 0 to the Days
                                    # where Days is a number of days between last and first elements of the range
                                    # (let $s stores a start of the range)
        $s.AddDays($_)              # output to the pipe a date = first date + number of the current iteration
    }                               # filter returns all dates for each range
}                                   # dates started from first element and ended to last element
$c=@{}                              # define hashtable @{key=date; value=count}
$args|d|%{++$c.$_}                  # count each date in a array of arrays of a date
,($c.Keys.Date|sort)|d|%{+$c.$_}    # call the filter via pipe with the array of sorted dates from hashtable keys

# Trace:
# call d @(2001-01-01, 2001-01-01) @(2001-01-01, 2001-01-03) @(2001-01-01, 2001-01-02) @(2001-01-03, 2001-01-03) @(2001-01-05, 2001-01-05)
# [pipe]=@(2001-01-01, 2001-01-01, 2001-01-02, 2001-01-03, 2001-01-01, 2001-01-02, 2001-01-03, 2001-01-05)
# $c=@{2001-01-03=2; 2001-01-01=3; 2001-01-05=1; 2001-01-02=2}
# call d @(2001-01-01, 2001-01-02, 2001-01-03, 2001-01-05)
# [pipe]=@(2001-01-01, 2001-01-02, 2001-01-03, 2001-01-04, 2001-01-05)
# [output]=@(3, 2, 2, 0, 1)

Thanks! $cnt.Keys.Date of course.

-3 bytes: function replaced with scriptblock. golfed and ungolfed codes are tested.

-5 bytes: scriptblock replaced on filter. Call of a filter is more compact.

J, 43 bytes
(],.[:+/@,"2="{~)&:((>./(]+i.@>:@-)<./)"1),

the input is a list of pairs of integers, where each integer is the offset from any arbitrary common 0-day.
ungolfed
(] ,. [: +/@,"2 ="{~)&:((>./ (] + i.@>:@-) <./)"1) ,

explanation
structure is:
(A)&:(B) C

C creates a hook that gives the main verb A&:B the input on the left and the input flattened on the right
B aka ((>./ (] + i.@>:@-) <./)"1) takes the min and max of a list and returns the resulting range, and acts with rank 1.  hence it gives the total range on the right, and the individual ranges on the left.
A then uses = with rank "0 _ (ie, rank of {) to count how many times each input appears in any of the ranges.  finally it zips every year with those counts.

Try it online!

JavaScript (Node.js), 80 bytes
(a,u=[])=>a.map(g=([p,q])=>p>q||g([p,q-864e5],u[z=(q-a[0][0])/864e5]=-~u[z]))&&u

Try it online!
undefined means zero; First element should start earliest
(a,u=[])=>a.map(g=([p,q])=>p>q||g([p,q-1],u[z=(q-a[0][0])/864e5]=-~u[z]))&&u is shorter if you only see elements and use more stack

You should ask for confirmation that substituting another value for 0 is acceptable.

Julia 0.6, 77 bytes
M->[println(sum(d∈M[r,1]:M[r,2]for r∈1:size(M,1)))for d∈M[1]:max(M...)]

Try it online!
Inspired by @DeadPossum's Python solution.
Takes input as a matrix, where each row has two dates: the starting and ending dates of an input range. Assumes the input has the earliest date first, and that each row has the starting date first, but assumes no sorting beyond that between different rows.

Older solution:
Julia 0.6, 124 bytes
R->(t=Dict();[[d∈keys(t)?t[d]+=1:t[d]=1 for d∈g]for g∈R];[d∈keys(t)?t[d]:0 for d∈min(keys(t)...):max(keys(t)...)])

Try it online!
Accepts input as an array of date ranges. Does not assume any sorting among the different ranges in the array.

Ruby, 70 bytes
->s{f,=s.min;(p s.count{|a,b|(f-a)*(f-b)<=0};f+=86400)until f>s[0][1]}

Try it online!
Input:
Array of pairs of dates, sorted by ending date descending.

R (70)
function(x)(function(.)tabulate(.-min(.)+1))(unlist(Map(seq,x$S,x$E,"d")))

Presumes a data frame x with two columns (Start and End or possibly S and E) with dates (class Date).
Try it online

Hi, could you include TIO links (see other answers) with an example input/output? It's not cheating to include a package, but library(magrittr) needs to be included in the byte counts.

Also as per consensus submissions need to be full functions or programs, not snippets, so if you go with a function whose sole argument is xyour answer starts with function(x) and then the body of the function.


text:
Nonogram line brute-force solving
Background
Nonogram, also known as Picross or Griddlers, is a puzzle where the objective is to determine if each cell on the 2D grid should be colored or left blank, using the numbers of consecutive colored cells on each line.
The following is an example Nonogram puzzle with solution.

The problem is, some commercial Nonogram games/mobile apps have puzzles which are not solvable by hand (e.g. have multiple solutions, or require deep backtracking). However, they also offer some lives to the player, where one life is lost when you try to color a cell whose correct answer is blank. So now it's time to brute-force those nasty "puzzles"!
In order to simplify the task, imagine just one line with its clue and nothing else:
3 7 | _ _ _ _ _  _ _ _ _ _  _ _ _ _ _

The [3,7] are the clues, and the line length is 15 cells. Since it has multiple possible solutions, we need to risk some lives in order to fully solve this line (i.e. determine all colored cells).
Challenge
Given a line with clues (a list of positive integers) and the line length, find the maximum number of lives you will lose, assuming that you brute-force the line with optimal strategy.
Note that you always guess colored cells. In actual games, guessing empty cells (either right or wrong) have no effect on your lives, so you can't "solve" the puzzle that way.
Also, you can assume the input always represents a valid Nonogram line, so you don't need to worry about something like [6], 5.
Explanation
Let's look at some simpler examples first.
[1,2], 5
There are exactly three possibilities for this line (O is a colored cell, . is an empty one):
O . O O .
O . . O O
. O . O O

If we try coloring cell 0 (0-based index from left), one of the following happens:

The cell is correctly colored. Now we have two possibilities, and we can choose between cell 2 and cell 4 in order to fully solve the line. Either case, we will lose one life in the worst case.
The cell is empty, and we lose a life. In this case, we have already identified the unique solution to this line, so we're done with 1 life lost.

Therefore, the answer for [1,2], 5 is 1.
[5], 10
Binary search? Nope.
The most obvious first choice is 4 or 5, which will reveal one possibility if it's blank (at a cost of 1 life). Let's say we chose 4 first. If cell 4 is indeed colored, we extend it to the left, i.e. try 3, 2, 1 and 0 until a life is lost (or cell 0 is colored, then we end up spending no lives at all). Whenever a life is lost, we can uniquely determine the solution, e.g. if we see something like this:
_ _ X O O _ _ _ _ _

then we already know the answer is this:
. . . O O O O O . .

Therefore, the answer for [5], 10 is also 1.
[3,7], 15
Start with cell 11, which, if empty, will reveal the following solution right away.
O O O . O O O O O O O X . . .

Then try 12, which, if empty, gives two possibilities which can be solved at the cost of 1 extra life.
O O O . . O O O O O O O X . .
. O O O . O O O O O O O X . .

Now try 2. If empty, it leads to three possibilities which can be solved similarly to the [1,2], 5 example.
. . X O O O . O O O O O O O .
. . X O O O . . O O O O O O O
. . X . O O O . O O O O O O O

If you keep minimizing the risk in this manner, you can reach any solution with max. 2 lives spent.
Test Cases
[1,2] 5 => 1
[2] 5 => 2
[1] 5 => 4
[] 5 => 0
[5] 10 => 1
[2,1,5] 10 => 0
[2,4] 10 => 2
[6] 15 => 2
[5] 15 => 2
[4] 15 => 3
[3,7] 15 => 2
[3,4] 15 => 3
[2,2,4] 15 => 4
[1,1,1,1,1,1,1] 15 => 2

[2,1,1,3,1] 15 => 3
[1,1,1,2,1] 15 => 5

For the last two cases, the optimal strategy is not going through the minimum blanks, but simply going from left to right (or right to left). Thanks to @crashoz for pointing it out.
Rules
Standard code-golf rules apply. The shortest valid submission in bytes wins.
Bounty
If someone comes up with a polynomial-time algorithm (with the proof of correctness), I will award +100 bounty to such a solution.

What is the intended output for [6], 5?

When you make a guess, do you have to guess that the cell is black, or can you guess either black or white?

@LeakyNun It's an invalid line. You can assume the input is always a valid Nonogram line.

@feersum You always guess colored cells. In actual games, guessing an empty cell (either right or wrong) has no effect on your lives, so you can't get any feedback with it.

Fantastic challenge

Has there been a nonogram challenge that's just: Given 2 2D array, output the intended nonogram.

@MagicOctopusUrn Yes

I have a problem with the last two tests, it seems to me that the optimal guessing strategy for these would return 3 and 5, by brute-forcing from right to left

@crashoz I agree that it's indeed a valid and optimal strategy in that case. I'll edit the test cases, and it shouldn't take too many additional bytes for the (only) existing answer.

Ruby, 85 bytes
f=->l,n,s=n-l.sum-l.size+1{*a,b=l;b&&s>0?(a[0]?1+f[a,n-b-2,s-1]:(n.to_f/b).ceil-1):0}

Try it online!
Explanation
The first step is to establish a recursive divide and conquer strategy to solve subproblems.
I will use the variables \$l=[l_1,l_2,...,l_x]\$ for the list of clues, \$x\$ for the number of clues and \$n\$ for the number of cells.
Try to fit the last clue \$l_x\$:
We test the cell at \$n-l_x\$
(1) If it's empty: then all of the clues are before \$n-l_x\$.
So we lose a life and we call recursively \$1+f(l,n-l_x)\$
(2) If it's colored:
We are not sure how to place the last clue, so we test every cells to the right until finding an empty one
The worst case is finding the empty cell at the last index, we lose a life, but we have placed the last clue
so we can call recursively \$1+f(\tilde{l},n-l_x-2)\$ where \$\tilde{l}\$ is \$l\$ without the last clue.
So we can get the number of lives with this function
$$
f(l,n)=\begin{cases}
  0, & \text{if } \sum_1^xl_i+x-1 \geq n\\
  \lceil \frac{n}{l_x} \rceil - 1 & \text{if } x= 1\\
  1+\max\begin{cases}
f(l,n-l_x)\\
f(\tilde{l},n-l_x-2)
  \end{cases}, & \text{otherwise}
\end{cases}
$$
Here is an example _ are unknown, X is a known space, O is a known colored cell and L is life lost
[2,2,4] 15                  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
(1) -> [2,2,4] 11           _ _ _ _ _ _ _ _ _ _ _ L X X X
    (1) -> [2,2,4] 7        _ _ _ _ _ _ _ L X X X L X X X
        0                   X X X L X X X L X X X L X X X
    (2) -> [2,2] 5          _ _ _ _ _ X O O O O L L X X X
        0                   O O X O O X O O O O L L X X X
(2) -> [2,2] 9              _ _ _ _ _ _ _ _ _ X O O O O L
    (1) -> [2,2] 7          _ _ _ _ _ _ _ L X X O O O O L
        (1) -> [2,2] 5      _ _ _ _ _ L X L X X O O O O L
            0               O O X O O L X L X X O O O O L
        (2) -> [2] 3        _ _ _ X O O L L X X O O O O L
            1               O O L X O O L L X X O O O O L
    (2) -> [2] 5            _ _ _ _ _ X O O L X O O O O L
        2                   O O L L X X O O L X O O O O L

It makes a binary tree, to get the number of lives lost, we just need to count the maximum height of the tree.
However this makes it \$\mathcal{O}(2^n)\$ because we evaluate all of the branches. We can do better.
Let's define a cost function \$h\$ that will help us "choose" the right branch at each step.
$$
h(l,n)=n - \sum_1^xl_i-x+1
$$
\$h\$ counts the number of superfuous spaces we have if we pack all the clues with one space in between.
So it is essentially an indicator of how much lives we are going to need to solve the instance, the higher it is,
the more lives are necessary. The idea is to apply this indicator on our recursive formula.
By definition of \$h\$ we have,
$$
\begin{align}
h(l,n-l_x) &= n - l_x - \sum_1^xl_i-x+1\\
& =(n - \sum_1^xl_i-x+1) - l_x\\
& = h(l,n) - l_x
\end{align}
$$
And,
$$
\begin{align}
h(\tilde{l},n-l_x-2) &= n - l_x - 2 - \sum_1^{x-1}l_i-(x-1)+1\\
& =(n - \sum_1^xl_i-x+1) - 1\\
& = h(l,n) - 1
\end{align}
$$
Then,
$$
h(l,n)=\begin{cases}
  \leq 0, & \text{if } \sum_1^xl_i+x-1 \geq n\\
  n - l_x, & \text{if } x=1\\
  \max\begin{cases}
h(l,n-l_x)+l_x\\
h(\tilde{l},n-l_x-2)+1
  \end{cases}, & \text{otherwise}
\end{cases}
$$
We want to maximize \$h\$ at each step to get the worst case so let's check the difference between the two expressions in the recurrence
$$
[h(l,n-l_x)+l_x] - [h(\tilde{l},n-l_x-2)+1]\\
\begin{align}
 &= n-l_x-n - \sum_1^xl_i-x+1 + l_x - [n-l_x-2 -\sum_1^{x-1}l_i-(x-1)+1+1]\\
 &=-2
\end{align}
$$
$$
\begin{align}
  [h(l,n-l_x)+l_x] - [h(\tilde{l},n-l_x-2)+1] &=-2\\
  [h(l,n-l_x)+l_x] - [h(\tilde{l},n-l_x-2)+1] &< 0\\
  [h(l,n-l_x)+l_x] &< [h(\tilde{l},n-l_x-2)+1]
\end{align}
$$
So the 2nd expression is always the max, we can remove the first one
$$
h(l,n)=\begin{cases}
  \leq 0, & \text{if } \sum_1^xl_i+x-1 \geq n\\
  n - l_x, & \text{if } x=1\\
  h(\tilde{l},n-l_x-2)+1 & \text{otherwise}
\end{cases}
$$
Finally this recursive definition of \$h\$ shows us that option (2) in function \$f\$ is always the worst case (giving the maximum number of possibilities i.e. maximizing \$h\$)
$$
f(l,n)=\begin{cases}
  0, & \text{if } \sum_1^xl_i+x-1 \geq n\\
  \lceil \frac{n}{l_x} \rceil - 1 & \text{if } x= 1\\
  1+ f(\tilde{l},n-l_x-2), & \text{otherwise}
\end{cases}
$$
Every step we decrease \$n\$ by at least 3 and there is now a single recursive call, complexity is \$\mathcal{O}(n)\$

Welcome to PPCG, incredible first post!

@cole It's not their first post, but it surely is incredible! Very clever approach +1

Awesome work. I'll award the bounty 2 days later, if no one finds any serious logical flaw until then.

Python, 303 289 bytes
First golf in a long time, so there may be a lot of excess fat. (Thanks Jo King for finding 14 bytes-worth.)
Function f generates all the possible arrangements (though always with a blank as the first character, but that's fine as long as we increment the length by 1 before we call it). Function g picks the position with the fewest number of blanks and recurses. Function h puts them together.
f=lambda l,n:["."*i+"X"*l[0]+c for i in range(1,n-l[0]+1)for c in f(l[1:],n-i-l[0])]if l else["."*n]
def g(q,n):O,X=min([[[p[:i]+p[i+1:]for p in q if p[i]==u]for u in".X"]for i in range(n)],key=lambda x:len(x[0]));return(len(q)>1)*1and max(1+g(O,n-1),g(X,n-1))
h=lambda l,n:g(f(l,n+1),n+1)

The examples all run fine:
>>> h([3,7],15)
2
>>> h([3,4],15)
3
>>> h([1,1,1,2,1],15)
6

Minor inprovements for 289 bytes

Are you allowed to return False for 0? If so, you can change (len(q)>1)*1and to len(q)>1and. If you are not allowed to return False for0, then do that, but change g(f(l,n+1),n+1) to 1*g(f(l,n+1),n+1) and it will still save one byte

Even better: in the case False is not allowed for 0, instead of changing g(f(l,n+1),n+1) to 1*g(f(l,n+1),n+1), change it to +g(f(l,n+1),n+1)

Also, you don't need to count the h= in your byte count

288 bytes.

Sorry, but the last two test cases are changed. Could you fix the submission?

Just saw this, sorry. Looks like @crashoz has found an infinitely better solution :-)

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
String Array to JSON String
Introduction
I've seen throughout the code-golf challenges several simple tasks involving JSON, such as interpreting JSON strings with RegExs,  and almost every other manipulation I could think of.
In a binding for AppleScript that I was using for a Node project, I noticed that objects would be returned in a strange way: there would be an array of properties in string form, instead of a JSON object being returned as expected. This is where the challenge comes in...
Algorithm

Add { to beginning of the output string
Iterate over all entries, adding them to the output string, delimited by ,
Add } to the end of the output string
Print out the output string

Challenge
Make this strange return format usable. Convert an array of JSON 'key:value's (in string form) to a full JSON object string.
Rules

Any language that can do string manipulations allowed
Must print out JSON string with surrounding curly braces {}, and double quotes "" around string values AND all properties ("property":"value" or "property":3.14, etc.)
Must return a valid, parseable JSON string
Lowest byte count wins per language

Example Input and Output
Input:

['prop1:"val1"', 'prop2:12', 'prop3:3.14', 'prop4:false']

Output:

'{"prop1":"val1", "prop2":12, "prop3":3.14, "prop4":false}'

Welcome to ppcg.SE! Hope you have a great time here.

We don't put languages in boxes ^^

This challenge seems to be a [tag:code-golf] challenge, but it doesn't say in the post. Could you make it more clear?

This needs a tag for a challenge type.  I (like JungHwanMin) am assuming code golf but it really needs a tag.

Hello, and welcome to the site.  I'm voting to close this as unclear.  There are a couple of things I find unclear.  The first is that terms like "golfing" and "functional" languages are unclear, there are tons of edge cases.  I'd recommend getting rid of the bonuses altogether, which would make this challenge clearer and better.  It's also not clear to me exactly what the process is to change the strings to json is.  I think it ought to be defined much more concretely.

Your test case does not seem to match your description.  In the test case it seems that quotations were placed around attribute names, but that is not apparent in your specification.

Suggested test-cases: a key containing :, a value containing :, same for ,.

Whats the actual input format? A list of strings? What characters can be in the string? ie, can the value or key contain a : or "?

The input format is either a string (or cstring, if unsupported) single-dimensional array. The input will only involve ASCII characters. The value can contain " (as \") and :, but the property can't, as the property isn't a string in the input format (being in the format 'property:"value"' for strings in an entry), so it wouldn't support string escape sequences.

Rule clarification please: must be input REALLY a JSON array of strings, or an array or array-like thing that is not necessarily a JSON array?

Retina, 23 bytes
%0`\w+
"$&"
¶
,
.+
{$&}

Try it online! Explanation:
%0`\w+
"$&"

Quote all of the keys.
¶
,

Join the array elements together.
.+
{$&}

Wrap the result in brackets. This can also be done using the following code for the same byte count:
^
{
$
}

JavaScript (Node.js), 35 bytes
a=>JSON.stringify(eval(`({${a}})`))

Try it online! 43 bytes without builtins:
a=>`{${a.map(s=>s.replace(/\w+/,`"$&"`))}}`

Try it online!

C 108
Thanks to Jonathan Frech this answer is now incredibly shorter
Thanks to @ceilingcat for some very nice pieces of golfing - now even shorter
i;main(c,v)char**v;{for(;++i<c;printf("%c\"%s\":%s",!~-i*79+44,v[i],++*v))*(*v=index(i[v],58))=0;puts("}");}

Try it online!

113 bytes, keeping with using a main function.

112 bytes.

@JonathanFrech I would never have come up with !~-i++*79+44  That's not just golfed better - it's a better answer.  Do you want to post it separately or shall i edit my answer?

Regarding the golf: (i==1?"{":",") <-> (i==1?'{':',') (when using %c instead of %s) <-> (i==1?123:44) (substituting actual ASCII values) <-> 44+(123-44)*(i==1) <-> 44+79*(i==1) <-> 44+79*!(i!=1) <-> 44+79*!(i-1) <-> 44+79*!~-i <-> !~-i*79+44. The post-increment was used with regards to the entire program (not locally explainable). Regarding the posting: feel free to use the golfs in your post.

Scala, 79 bytes
Essentially Neil's JS solve.

Try it online!
def f(a:Seq[String])="{"+a.map(_.replaceAll("\\w+","\"$0\"")).mkString(",")+"}"

Python 3, 59 bytes
lambda x:"{%s}"%",".join('"'+a.replace(":",'":')for a in x)

Try it online!
-6 bytes thanks to ovs

59 bytes using a.replace(':','":')

Lua, 122 bytes
loadstring[[s="{"for i,v in ipairs(...)do x,y=v:match("(.-):(.+)")s=s.."\""..x.."\":"..y..","end return s:sub(1,-2).."}"]]

Try it online!

This is an anonymous function. It technically doesn't "print out JSON string [...]", but instead it returns this string, so that when calling it you could print. I did that because I needed to first convert the input from string to an actual list, and I did that on the argument of the function call.
If this makes my answer invalid I'll move the string to table (list) "parser" from the footer to the actual code. But I don't think it should, because the input shown as a table, so the code that takes a string and transforms it into a table shouldn't count.

Ruby, 41 40 bytes
->a{?{+a.map{_1.sub /\w+/,'"\&"'}*?,+?}}

Essentially Neil's JS solve.
Attempt This Online!

POSIX sh (sed + ShellShoccar-jpn/Parsrs makrj.sh), 33 bytes
Assumes values may have colons but properties shall never have colons, spaces, tabs, or periods.
sed 's/\([^:]*\):/.\1 /'|makrj.sh

Usage
Input via standard input. Each line represents each item of an array.
Commented
# "prop:item"
sed 's/\([^:]*\):/.\1 /'|
# ".prop item" is JSONPath-value format
makrj.sh
# JSON object

Example run on Termux
~ $ sh makrj.sh -h
Usage : makrj.sh [JSON_value_textfile]
Wed Sep 14 22:19:55 JST 2016
~ $ cat jsss;echo;cat jsss | sed 's/\([^:]*\):/.\1 /'|sh makrj.sh
prop1:"val1"
prop2:12
prop3:3.14
prop4:false

{
"prop1":"val1",
"prop2":12,
"prop3":3.14,
"prop4":false
}
~$

Go, 116 bytes
import."strings"
func f(s[]string)string{for i,l:=range s{s[i]=`"`+Replace(l,`:`,`":`,1)}
return"{"+Join(s,",")+"}"}

Attempt This Online!

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
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.

Related

Are we allowed to print each card to STDOUT instead of returning a list/array?

Can we use T instead of 10?

@KevinCruijssen no

@AJFaraday No for both my questions? So String list/array and 10 are both mandatory?

@KevinCruijssen that’s correct. The initial question specifies the numbers 2 to 10, and an array of strings as an output.

Can we output C9 instead of 9C?

@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"

I was just wondering if you could get 23456789 by multiplying 2 smaller numbers... only to discover it's prime!

Can we output the two Js 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?

@EriktheOutgolfer I'm afraid it's pretty prescriptive, an array of strings.

@match Since the order of the output doesn't matter, maybe you can still create it with smaller numbers by ending it with 2 or 4 or anything else so it isn't a prime anymore.

As a poker aficionado, I have to second @KevinCruijssen 's comment of using T - it's much, much more common.

@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.

@match The product of two positive integers is always smaller than their concatenation.

@match You could do 91**3*35 if your language has a short built-in for cube.

I 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

@JoKing Mostly because in languages which have an array structure, outputting to STDOUT might be shorter than collecting items into an array.

I don't think there's anything wrong with having shorter code...

@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.

The playing field isn't very level when you've excluded a majority of languages

@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?

Rules 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 the spec explicitly states an array of strings.

That 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.

What about "Rules of Bridge" in the returned array of strings? :)

@billpg I kind of want to allow that. It wouldn't be fair to make everyone do it now, tho.

Can we use lowercase letters?

JavaScript (ES6), 62 60 bytes
f=n=>n>51?'JJ':[('JQKA'[k=n>>2]||k-2)+'CDHS'[n&3],...f(-~n)]

Try it online!

Smooth moves!!!

I didn't know spread syntax existed until I read this -- very cool

Bash 43 34 bytes
d=({A,J,Q,K,{2..10}}{H,S,D,C} J J)

Try it online!

9 bytes shorter

I did not think braces were nestable. Thanks.

And here I was thinking "what language do I know that conveniently does direct products on lists of strings?"  I didn't even think about good old glob!

Technically brace expansion is not a glob pattern, it is its own special syntax

brainfuck, 200 197 bytes
+[[<+>->++<]>]+<++++<<+++[->+++>+++++>+>+<<<<]>+.<<.>>.--<<<[->>+++<<]>>+>[<<.>.-.+>.<<.<<[>>>+.>.<<.<+<-]>[-<+>>>+<<]>>.>.<<.>+++++++++.>.<<.>+.>.<<.>++++++.>.,++++[-<-------->]>[[-<+>]>]<<[<]>>>]

Try it online!
Uses one negative cell (+1 bytes to fix), wrapping cells (lots o' bytes to fix) and 0 on EOF (+2 bytes to remove dependancy).
Outputs
J J 10H 2H 3H 4H 5H 6H 7H 8H 9H AH JH KH QH 10S 2S 3S 4S 5S 6S 7S 8S 9S AS JS KS QS 10D 2D 3D 4D 5D 6D 7D 8D 9D AD JD KD QD 10C 2C 3C 4C 5C 6C 7C 8C 9C AC JC KC QC

Explanation:
+[[<+>->++<]>]  Sets the tape to powers of 2
          TAPE: 1 2 4 8 16 32 64 128 0 0'
+<++++<<+++[->+++>+++++>+>+<<<<]   Uses the 64 and the 128 to generate the suit letters
          TAPE: 1 2 4 8 16 32 0' 73 83 68 67
                                 I  S  D  C
>+.<<.>>.--<<     Prints the Jokers
<[->>+++<<]>>+>   Uses the 16 to create 49
          TAPE: 1 2 4 8 0 32 49 72' 83 68 67
                                 H   S  D  C
[  Loop over the suits
   <<.>.-.+>.<<.<<      Print the 10 card with a leading space
          TAPE: 1 2 4 8' 0 32 49 Suit
   [>>>+.>.<<.<+<-]  Use the 8 to print the other 8 number cards
          TAPE: 1 2 4 0' 8 32 57 Suit
   >[-<+>>>+<<]      Move the 8 back into place while also adding it to the 57
          TAPE: 1 2 4 8 0' 32 65 Suit

   >>.>.<<.         Print the Ace
   >+++++++++.>.<<. Print the Jack
   >+.>.<<.         Print the King
   >++++++.>.<<.    Print the Queen
          TAPE: 1 2 4 8 0 32 81' Suit
   >>,    Clear the current suit
   ++++[-<-------->]    Subtract 32 to get back to 49 (reusing the space is longer than just subtracting 32)
          TAPE: 1 2 4 8 0 32 49 0' MoreSuits?
   >[[-<+>]>]<<[<]>>>   Shift all the remaining suits over one
          TAPE: 1 2 4 8 0 32 49 Suit?'
] End on the character of the next suit and repeat

That more than 2.5 time shorter than my solution. Well done.

05AB1E, 28 27 25 24 23 bytes
2TŸ.•-Ÿ•S«.•ôì•âJ„jjS«u

Try it online.
-1 byte thanks to @Emigna removing the S after "HSDC", because â does this implicitly.
Explanation:
2TŸ           # Push list in the range [2,10]: [2,3,4,5,6,7,8,9,10]
   .•-Ÿ•      # Push compressed string "ajqk"
        S     # Convert it to a list of characters: ["a","j","q","k"]
         «    # Merge the two lists together: [2,3,4,5,6,7,8,9,10,"a","j","q","k"]
.•ôì•         # Push compressed string "cdhs"
â             # Cartesian product of each (pair each character of both lists):
              #  [[2,"a"],[2,"d"],[2,"h"],...,["k","d"],["k","h"],["k","s"]]
J             # Join each pair together to a single string:
              #  ["2a","2d","2h",...,"kd","kh","ks"]
„jjS          # Push string "jj", and convert it to a list of characters: ["j","j"]
    «         # Merge both lists together:
              #  ["2a","2d","2h",...,"kd","kh","ks","j","j"]
     u        # Convert everything to uppercase:
              #  ["2A","2D","2H",...,"KD","KH","KS","J","J"]
              # (and output the result implicitly)

See this 05AB1E tip of mine (section How to compress strings not part of the dictionary?) to understand why .•-Ÿ• is "ajqk" and .•ôì• is "cdhs".

brainfuck, 550 504 bytes
++++++++++[>+++>+++++>+++++++<<<-]>++>->[>+>+>+>+<<<<-]>----->++++.<<<<.>>>>.<<<<.>>>>>--->+++++++++++++<<<<<.-.+>>>>.<<<<<.>.-.+>>>>+.<<<<<.>.-.+>>>>++++.-----<<<<<.>.-.+>>>>>.<<<<<<.>>++++++++[-<+.>>>>.<<<<<.>.>>>>+.<<<<<.>.>>>>++++.-----<<<<<.>.>>>>>.<<<<<<.>>]>.>>.<<<<<.>>>>.>.<<<<<.>>>>+.>.<<<<<.>>>>++++++.>.<<<<<.>>>.>>+.<<<<<.>>>>.>.<<<<<.>>>>------.>.<<<<<.>>>>-.>.<<<<<.>>>.>>++++.<<<<<.>>>>.>.<<<<<.>>>>+.>.<<<<<.>>>>++++++.>.<<<<<.>>>.>>>.<<<<<<.>>>>.>>.<<<<<<.>>>>------.>>.<<<<<<.>>>>-.>>.

Try it online!
Old answer, also online!

Java 10, 153 151 125 77 75 bytes
v->("AJQK2345678910".replaceAll("1?.","$0H,$0S,$0D,$0C,")+"J,J").split(",")

-28 bytes thanks to @OlivierGrégoire.
-50 bytes thanks to @mazzy.
Try it online.
Explanation:
v->                      // Method with empty unused parameter and String-array return-type
  "AJQK2345678910"
   .replaceAll("1?.",    //  Replace every loose character (or "10" as single char)
     "$0H,$0S,$0D,$0C,") //  with "cH,cS,cD,cC,", where c is the character
   +"J,J")               //  Append "J,J"
  .split(",")            //  And split everything by commas

r[i++]=r[i]="J"; No need for the final ++.

v->{var r="J J";for(var s:"HSDC".split(""))for(var c:"A,2,3,4,5,6,7,8,9,10,J,Q,K".split(","))r+=" "+c+s;return r.split(" ");} (125 bytes)

try "AJQK2345678910".replace("1?.","$0H,$0S,$0D,$0C,")+"J,J" and split it.

Smart @mazzy Thanks. And was already editing it, Olivier. :)

cool! I believe it is possible to remove 2 bytes more - brackets in the pattern. see https://regex101.com/r/aDbz9C/1/

@mazzy Oh, didn't even knew $0 was possible in Java. TIL, thanks. :)

APL (Dyalog Unicode), 29 bytes
1 byte saved thanks to Probie by using 1+⍳9 instead of 1↓⍳10
'JJ',,'HCDS'∘.,⍨'AKJQ',⍕¨1+⍳9

Try it online!
This is a full program. In the TIO link, I have enabled boxing so that the individual elements of the array can be distinguished.
Here is the boxed output.
┌─┬─┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬───┬───┬───┬───┐
│J│J│AH│AC│AD│AS│KH│KC│KD│KS│JH│JC│JD│JS│QH│QC│QD│QS│2H│2C│2D│2S│3H│3C│3D│3S│4H│4C│4D│4S│5H│5C│5D│5S│6H│6C│6D│6S│7H│7C│7D│7S│8H│8C│8D│8S│9H│9C│9D│9S│10H│10C│10D│10S│
└─┴─┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴───┴───┴───┴───┘

'JJ', 2 jokers concatenated to
, the raveled form of
∘.,⍨ the matrix created by concatenating every combination of

'HCDS' this string against
'AKJQ', this string with

⍕¨ the stringified forms of each of

1+⍳9 the numbers 2..10 (1 plus the range 1..9)

I've changed the indentation of your list in the explanation. It looked a bit weird with the two and three dots.. If that was intended for some reason, feel free to rollback.

@KevinCruijssen Thanks, I couldn't figure out how to do that, so I used multiple bullet points hah

Yeah, I thought so, that's why I changed it. :) You need multiples of four leading spaces before the - to indent it.

Befunge-98 (FBBI), 75 bytes
j4d*1-2k:d%4+1g:'0-!#v_>,d/1g,' ,!#v_3
CHSDA234567890JQK@;1'< ^,;,k2"J J" <

Try it online!
Program structure

At first, the stack is filled with 0's, and j does not jump over the initialisation. The initialisation pushes 4 * 13 = 52, which is the program counter. In the following iterations the trailing 3 causes the pointer to jump over this part.
1-2k:d%4+1g,d/1g,' ,!#v_  Main loop

1-                        decrement counter
  2k:                     duplicate counter three times
     d%                   counter mod 13 ...
       4+                 ... + 4 is the position of the card in the Data section
         1g,              get the card from row 1 and print it
            d/            counter / 13 is the position of the suit in the Data section
              1g,         get the suit from row 1 and print it
                 ' ,      print a space as seperator
                    !     negate the counter (0 for non-zero, 1 for 0)
                       _  If the counter is 0, move West ...
                     #v   ... and move to the termination
                          otherwise, continue with the next iteration

Code that prints 10:
'0-!#v_>    Checks if Card is '0'

'0-         subtract the '0' from the card
   !        negate (1 for '0', 0 for all other cards)
      _     If card was '0', move West
    #v        and go South to print '10'
            Else continue to go East

  ;1'< ^,;  Prints '10'

     <      Go West
   1'       Push '1'
  ;         Jump to ...
         ;  ... the next semicolon
        ,   Print '1'
       ^    Go back to the main loop
            The '0' will be printed by the main loop

Termination:
@; ... ;,k2"J J" <

                 <  Go West
           "J J"    Push "J J"
        ,k2         Print it
       ;            Jump to ...
 ;                  ... the next semicolon
@                   terminate the program

R, 65 bytes
c(outer(c('A',2:10,J<-'J','Q','K'),c('S','D','H','C'),paste),J,J)

Try it online!
-2 Bytes thanks to @Giuseppe and @JayCe suggestions

This was my exact answer, although I think I used double quotes instead of single quotes.

Sorry, have I double-posted your answer ? I checked but I couldn't find any R answer...

Oh no I had just typed it all up myself in TIO before seeing yours :-)

Yes outer is definitely the way to go here! Although whitespace is premitted as per spec so you can save one byte by using paste. @Giuseppe too.

I pointed this out on JayCe's answer, but you can set x<-'J' inside the outer and then re-use x as a variable in the outermost c() statement to shave off a byte: Try it online!

Modified: thanks to both @JayCe and @ Giuseppe ;)

Powershell, 63 61 59 56 bytes
-3 bytes: thanks ConnorLSW
2..10+'AJQK'[0..3]|%{"$_`H";"$_`S";"$_`D";"$_`C"};,'J'*2

-3 using string to array for the first part : 2..10+'AJQK'[0..4]|%{"$_`H";"$_`S";"$_`D";"$_`C"};,'J'*2

cool! any idea how to remove ````?

as far as I know that's the cheapest way to break up a variable in a string, I took a look at a loop but it's more expensive by 2 chars to do it that way.

Perl 5, 41 bytes
sub{J,J,map<"$_"{S,D,H,C}>,A,2..10,J,Q,K}

Try it online!

This has taught me something really interesting about globbing. Nice.

Python 3, 67 64 bytes
print(*[a+b for a in['10',*'A23456789JQK']for b in'CHSD'],*'JJ')

Try it online!

Python 2, 78 76 74 68 bytes
print['1'*(a<'1')+a+b for a in'A234567890JQK'for b in'CHSD']+['J']*2

Try it online!
Alt:
Python 2, 68 bytes
print[a+b for a in['10']+list('A23456789JQK')for b in'CHSD']+['J']*2

print['1'[a>'0':]+a+b for a in'A234567890JQK'for b in'CHSD']+['J']*2

saved

-3 bytes, thanks to ovs

That's a pretty thorough answer...

64 bytes

If we don't have to use print, can't we do [*[a+b for a in['10',*'A23456789JQK']for b in'CHSD'],*'JJ'] in 59 bytes. The Haskell solution doesn't need to output to stdout, why would Python?

K (ngn/k), 30 bytes
"JJ",/("AKQJ",$2+!9),'/:"SHDC"

Try it online!
!9 is the list 0 1 ... 8
2+!9 is the list 2 3 ... 10
$ to string
, concatenate
,'/: concatenate each with each right, i.e. Cartesian product; normally it's ,/:\: or ,\:/: but on the right we have only scalars ("SHDC"), so we can use ' instead of \:
"JJ",/ join (concat reduce) the list on the right using "JJ" as initial value for the reduction

MS-SQL, 137 bytes
SELECT v.value+s.value
FROM STRING_SPLIT('A-2-3-4-5-6-7-8-9-10-J-Q-K','-')v,STRING_SPLIT('H-S-D-C--','-')s
WHERE s.value>''OR v.value='J'

An array of values in SQL is returned as separate query rows. Uses the STRING_SPLIT function introduced in SQL 2016.
It includes the jokers by adding two "blank string" suits to take advantage of the existing "J" for Jack, then filtering out rows we don't want. Shorter than using UNION ALL statements to add the jokers.

What happens if you make the second argument for STRING_SPLIT an empty string? I don’t use MS-SQL, but in many languages it would give you all the characters in an array.

@AJFaraday That would be handy, but it doesn't work, you get Procedure expects parameter 'separator' of type 'nchar(1)/nvarchar(1)'. It would also be handy for golfing if it defaulted to a comma if you left out the second parameter, but it doesn't support that either. Another item for the GolfSQL language I'll probably never get around to writing :)

Japt, 32 30 26 bytes
'J²¬c"JQKA"¬c9õÄ)ï+"CHSD"q

Test it
'J²¬c"JQKA"¬c9õÄ)ï+"CHSD"q
'J                             :Literal "J"
  ²                            :Repeat twice
   ¬                           :Split
    c                          :Concatenate
     "JQKA"¬                   :  Split "JQKA"
            c                  :  Concatenate
             9õ                :    Range [1,9]
               Ä               :    Add 1 to each
                )              :  End concatenation
                 ï             :  Cartesian Product
                   "CHSD"q     :    Split "CHSD"
                  +            :  Join each pair to a string

PHP, 108 99 97 Bytes
Try it online!
Try it online! (Edit 1)
Code
<?php $r=[J,J];foreach([A,J,Q,K,2,3,4,5,6,7,8,9,10]as$t)
$r=array_merge($r,[H.$t,S.$t,D.$t,C.$t]);

Tried to use purely php funcions, but bytecount was lower with a loop :(
Output (using print_r)
Array
(
[0] => J
[1] => J
[2] => HA
[3] => SA
[4] => DA
[5] => CA
[6] => HJ
[7] => SJ
[8] => DJ
[9] => CJ
[10] => HQ
[11] => SQ
[12] => DQ
[13] => CQ
[14] => HK
[15] => SK
[16] => DK
[17] => CK
[18] => H2
[19] => S2
[20] => D2
[21] => C2
[22] => H3
[23] => S3
[24] => D3
[25] => C3
[26] => H4
[27] => S4
[28] => D4
[29] => C4
[30] => H5
[31] => S5
[32] => D5
[33] => C5
[34] => H6
[35] => S6
[36] => D6
[37] => C6
[38] => H7
[39] => S7
[40] => D7
[41] => C7
[42] => H8
[43] => S8
[44] => D8
[45] => C8
[46] => H9
[47] => S9
[48] => D9
[49] => C9
[50] => H10
[51] => S10
[52] => D10
[53] => C10
)

Edit
Thanks to @JoKing by suggesting change explode(" ","H$t S$t D$t C$t") for [H.$t,S.$t,D.$t,C.$t]

Wouldn't [H.$t,S.$t,D.$t,C.$t] be shorter than explode?

You are absolutely right, gonna take your advise, thank you.

73 bytes: Try it online!

@Night2, nice aproach, tried something similar when i was writing this answer, but the OP asks for a String array as output.

@FranciscoHahn, sorry, I didn't notice that! Here is a 87 bytes version then: Try it online!

@Nigth2 i had no idea you can use array_push($arr, $item1,$item2,$item3...$itemN) like that, nice one

Ruby, 61 bytes
->{[*0..52,52].map{|x|['JAKQ'[w=x%13]||w-2,'SDHC'[x/13]]*''}}

Try it online!

That's some skill to use the J for both Jack and Joker :-)

Can't you save 4 bytes by leaving out the ->{...}? It runs on its own and doesn't need parameters, so it shouldn't need to be a lambda

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).
Try it online.

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()

Try it online.
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

SMBF, 169 bytes
␀ represents a literal NUL byte \x00.
<[.<]␀J J HA HK HQ HJ H01 H9 H8 H7 H6 H5 H4 H3 H2 SA SK SQ SJ S01 S9 S8 S7 S6 S5 S4 S3 S2 DA DK DQ DJ D01 D9 D8 D7 D6 D5 D4 D3 D2 CA CK CQ CJ C01 C9 C8 C7 C6 C5 C4 C3 C2

This is the naive solution.
Because this program contains a NUL byte, there's no easy way to use TIO. Run this in the Python interpreter using
data = bytearray(b'<[.<]\x00J J HA HK HQ HJ H01 H9 H8 H7 H6 H5 H4 H3 H2 SA SK SQ SJ S01 S9 S8 S7 S6 S5 S4 S3 S2 DA DK DQ DJ D01 D9 D8 D7 D6 D5 D4 D3 D2 CA CK CQ CJ C01 C9 C8 C7 C6 C5 C4 C3 C2')

TIO

@EriktheOutgolfer How did you generate that?

I opened the F12 developer tools, selected the text box by hovering, went to the console and, after I copied and pasted the part before the null byte, typed $0.value+='\0'.

Batch, 118 bytes
@for %%s in (C D H S)do @(for /l %%r in (2,1,10)do @echo %%r%%s)&for %%r in (J Q K A)do @echo %%r%%s
@echo J
@echo J

J, 41 bytes
'J';^:2,'HCDS',&.>/~(":&.>2+i.9),;/'AJQK'

Try it online!

'J';^:2,;&.>{_13<\'10';;/'23456789AJKQHCDS' slightly simpler but for 43.  I feel like there's more to shave here... but I can't see how.

@Jonah Yes, I also tried something similar and I'm sure my solution can be golfed further, but there are always new problems to be solved :)

C (gcc), 126 137 133 bytes
#define S(X)"A"X,"2"X,"3"X,"4"X,"5"X,"6"X,"7"X,"8"X,"9"X,"10"X,"J"X,"Q"X,"K"X,
#define c (char*[54]){S("S")S("D")S("H")S("C")"J","J"}

Try it online!
+11 bytes to be more complete thanks to Jakob.
-4 bytes thanks to Zachary
Mostly abusing of preprocessor to compress the suits. Could probably be out-golfed, but is pretty efficient all things considered.

I would argue that c is not a "[...] weird 'function' [...]" but rather an array declaration stored in a macro. Such a form of output is to my knowledge not permitted by default.

Except c is not an array, it would be an in-place literal. Each 'invokation' of c in the source will create a new copy of the array in the resulting executable (barring optimizations). Thus, the code char *a[] = c; char *b[] = c; create two deep copies of c. This behaviour is what you'd expect of a function as well.

If there was a challenge to output the integer zero, would you consider the C code c=0; a valid submission, viewing c as a function?

no, but I would consider #define z 0 valid. The reasoning is that: c=0; c++; x=c; results in x == 1 so c doesn't act much like a function. Meanwhile #define z 0 c=z; c++; x=z; does result in x == 0 so z acts like a function.

I do not think that is a fair comparision as you first change the supposed function, then only change the supposed function's return value. z=0;/**/c=z;c++;x=z; results in x==0, thus z acts like a function.

The issue there is that z is in a variable and is the value of that variable. Many languages use 'inline blocks' as a valid submission format (e.g. J's unnamed verbs) this is similar in that it can be inlined directly. Note that I would consider the equal length second line of char*c[]={...}; invalid as it does not do what a C function normally would (return a new value on the stack). If you need a function then a second line of char*[54]f(){return {...};} would work I think.

Nope, you need a declaration in order to use an initializer. And this is the main reason this approach isn't valid. Not only is the expansion of c not (used in) a function, but it doesn't produce a value. It's just syntax tied to a declaration.

No, you don't need a declaration. In a for loop you could have c[53] as identical to "J" without any variable being declared. That is exactly why I argue it is different. (the only issue being typing, but we abuse that all the time with our int functions taking pointers) Changing the line in the link to printf("%s ", (char*[54])c[i]) works fine. You could argue the need for +11 bytes to add the (char*[54]) in front of the array in c though.

Here is my reasoning why the macros are more functional than a variable declaration: Try it online!

I get your deep copy argument that macros are more function-esk than variables, though I do not think that is enough for them to be on par with functions regarding the I/O consensus.

Oops. You're right about initializers being expressions. I agree with Jonathan though that consensus is that a C submission must be a function or full program.

I agree that macro functions are definitely borderline (which c is, despite having no argument list). The relevant meta post states that "The default should be "programs or functions" This includes function-like constructs, including J's verbs and GolfScript's and CJam's blocks. I would argue that C macros are as function-like as J's verbs or GolfScript's blocks (though not CJam's blocks, as they can be assigned to variables and manipulated, the analogue of function pointers)

You can remove the space after S(X).Also, add a comma after its definition, then use remove each comma after its call.

Suggest char*[] instead of char*[54]

Pyth, 26 25 bytes
+ B\JsM*+tSTc"JQKA"1"CDHS

Saved a byte thanks to hakr14.
Try it here
Explanation
+ B\JsM*+tSTc"JQKA"1"CDHS
         tST                Get the range from 2 to 10...
        +   c"JQKA"1        ... plus the list ['J', 'Q', 'K', 'A'].
       *            "CDHS   Take the Cartesian product with the suits.
     sM                     Stick the ranks and suits together.
+ B\J                       Add the jokers.

+\J+\J and +*2]\J are equivalent and both 6 bytes, but the latter is considered better form, as it allows for up to 10 copies to be added before any additional bytes are needed.

@hakr14 True, but I'm not into code golf for the sake of writing the cleanest or most generalizable code.

+\J+\J can be replaced with + B\J to save a byte.

R, 67 66 bytes
c(paste(rep(c('A',2:10,J<-'J','Q','K'),4),c('S','D','H','C')),J,J)

Try it online!
Only one more byte than digEmAll's golfier solution. Inspired byGiuseppe's solution to this related challenge - the same Giuseppe who golfed one byte off by answer!
I'm posting separately since it's a slightly different approach taking advantage of the fact that 4 is not a divisor of 13 and that the output does not need to be in any particular order.

oh haha I didn't notice this, I commented this solution on the other one

@Giuseppe I was very close to comment instead of posting myself. I guess I just couldn't resist the urge to answer :)

iiiit's just as golfy as digemall's answer :-) try it online

@I was just experimenting with that :) so both digemall and I can golf one byte thanks to you :)

Javascript (ES6) 77 74 72 bytes
This is a complete program.
`J,J,${[..."A23456789JQK",10].map(c=>[..."SDHC"].map(s=>c+s))}`.split`,`

Nice.  You can save a few bytes by splitting on commas instead of concatenating:  BTJ,J,${[..."A23456789JQK","10"].map(c=>[..."SDHC"].map(s=>c+s))}BT.splitBT,BT  (where BT is a backtick).

Awesome suggestion! Thanks.

Perl 6,  43  42 bytes
{|(|(2..10),|<A J Q K>X~ <S D H C>),|<J J>}

Try it
{|(|(^9+2),|<A J Q K>X~ <S D H C>),|<J J>}

Try it from Jo King
Expanded:
{  # bare block lambda

    |(  # flatten into outer list

        |(  # flatten into left-side list for X~
          ^9 + 2
          # 0+2 ..^ 9+2
          #   2 ..^ 11
          #   2 ..  10
        ),
        |   # flatten into left-side list for X~

          < A J Q K >

      X~    # cross using &infix:« ~ » (string concatenation)

        <S D H C>

    ),
    |< J J > # flatten two `J`s into outer list
}

41 bytes

QBasic 4.5, 114 142 127 bytes
dim r$(54)
FOR i=1TO 52
m=i MOD 13
r$(i)=MID$("JQKA2345678910",1+m,1-(m=12))+MID$("CDHS",(i-1)\13+1,1)
NEXT
r$(53)="J
r$(54)="J

Release Notes:

V1.0 Initial deploy
V1.1 Misread the challenge requirements, so switched to a more expensive array r$. All the rest of the code is pretty much the same.
V1.2 Suggestions from @TaylorScott lead to a complete rewrite saving 15 bytes!

Sample output
If we add this snippet to our code, we can see what is put into r$:
for i = 1 to ubound(r$)
?r$(i)
next

QC
KC
AC
2C
3C
4C
5C
6C
7C
8C
9C
10C
JC
QD
KD
AD
[... snip ...]
6S
7S
8S
9S
10S
JS
J
J

But how? Well, let me tell you:
dim r$(54)          ' create a 54-slot array for our results
FOR i=1TO 52        ' Loop through the numbers 1-52 in var i
m=i MOD 13          ' Take i mod 13 to select a value (saved as m)
                    ' , and (not saved) i intdiv 13 to get a suit
r$(i)=              ' assigns to slot i in the result array
  MID$("JQKA2345678910"  ' a substring from the string with all the values
  ,1+m                   ' from position 1-13 (13 % 13 = 0, but QBasic strings are 1-based.
                         ' Hence the + 1)
  ,1-(m=12))             ' taking 1 char by default, and 2 for the Ten
                         ' Note that m=12 evaluates to 0 for 0-11, and to -1 for 12
  + MID$("CDHS",(i-1)\13+1,1)  ' and take 1 char from the suits-string
NEXT
r$(53)="J           ' Then append 2 jokers
r$(54)="J           ' These strings are auto-closed by the QBasic compiler.

This does not meet the Array of strings requirement, and printing to STDOUT is explicitly forbidden

@TaylorScott Thanks for noticing. Fixed now, @ 30 bytes extra.

I think that you should be able to get the bytecount down by dropping the a$ and b$ vars and using a line something like r$(i)=MID$("JQKA2345678910",1+m,1-(m=12))+MID$("CDHS",(i-1)\13+1,1)

@TaylorScott Thanks! That reshuffling in the values-string is particularly clever. Nice!

This is longer than just PRINT "<output>"

C (gcc, clang), 138 bytes
#define p(c)putchar(c)
int main(){for(char*q,*r="CDHS";*r;r++)for(q="A234567890JQK";*q;q++)(48==*q)&&p(49),p(*q),p(*r),p(32);puts("J J");}

Approach is to encode the sequences in character arrays.
Sample Output
AC AD AH AS 2C 2D 2H 2S 3C 3D 3H 3S 4C 4D 4H 4S 5C 5D 5H 5S 6C 6D 6H 6S 7C 7D 7H 7S 8C 8D 8H 8S 9C 9D 9H 9S 10C 10D 10H 10S JC JD JH JS QC QD QH QS KC KD KH KS J J

Try it online!

Hint: you can use a single printf to get rid of all putchars.

127 bytes.

Regarding your method of output, the OP does not allow printing.

Building on Jonathan Frech and Dennis 113 bytes

Oracle SQL, 164 bytes
Not a golfing language but...
SELECT CASE WHEN LEVEL>52THEN'J'ELSE DECODE(MOD(LEVEL,13),1,'A',11,'J',12,'Q',0,'K',MOD(LEVEL,13))||SUBSTR('HDSC',CEIL(LEVEL/13),1)END FROM DUAL CONNECT BY LEVEL<55

Try it online - SQL Fiddle

I love that someone answered this with Oracle SQL

postgres nearly beats this with just a string 172 bytes, 'select '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''

@dwana That is not an array of strings (or, since this is SQL, a set of rows). You would need to split the string into rows (or columns) to meet the question's specifications. If you want to do that as a separate PostgreSQL solution then I would like to see that.

sorry, didn't see the array requirement

Lua, 156 127 138 129 bytes
loadstring'r={"J","J"}for x=1,52 do p=x%4+1r[#r+1]=({"A",2,3,4,5,6,7,8,9,10,"J","Q","K"})[x%13+1]..("SDHC"):sub(p,p)end return r'

Try it online!
Based on Jo King's code.
As he suggested in the comments, my original answer wasn't valid (I'm still learning how code golf works ), and linked a better and valid answer. Then I made it smaller.

Original solution (156 bytes):
r={}s="SDHC"c={"J","Q","K"}t=table.insert for x in s:gmatch"."do for y=1,13 do t(r,(y==1 and"A"or y>10 and c[y-10]or y)..x)end end for _=1,2 do t(r, "J")end
r={} -- initializes the result table
s="SDHC" -- initializes the suits' string, it's better to be a string because we're just looping through it
c={"J","Q","K"} -- initializes some of the special cards

t=table.insert -- stores the table.insert call inside the 't' variable

for x in s:gmatch"."do -- loops through the suits, calling each one 'x'
  for y=1,13 do -- 'y' is the current card

    t(r,(y==1 and"A"or y>10 and c[y-10]or y)..x) -- adds the card accompanied by the suit to the result ('r') table
      -- y==1 and"A"or y>10 and c[y-10]or y  means if we're at the first card, it's an "A", else if we're past the 10th card, it's a special card, else, it's the number itself

  end
end
for _=1,2 do t(r, "J")end -- loop 2 times, adding a "J" to the result table

I just want to say that I'm new to this Code Golf stuff, so if I'm doing something wrong, feel free to tell me.
I know this answer isn't one of the smallest, I just wanted to challenge myself.
If you have suggestions for reducing my code you can say too. :)

Welcome to the site!

@WW thanks! Hahah :D

What happens with the table r? Either you need to print it to STDOUT, or change this to a function and return r

I'm no expert with Lua, but here's a valid 142 byte anonymous function

138 bytes

Welcome and I hate the 15 character limitations.

Deadfish~, 1318 bytes
{{i}ddd}iiiic{d}iiic{ddd}dddddc{iiii}iicddddddc{ddd}ddddddc{iiii}iicddc{dddd}c{iiii}iic{i}dc{ddddd}dc{iiiii}dc{d}ddddc{ddd}dddddc{iiiii}dc{d}dddc{ddd}ddddddc{iiiii}dc{d}ic{dddd}c{iiiii}dciic{ddddd}dc{iiii}iiic{d}iic{ddd}dddddc{iiii}iiic{d}iiic{ddd}ddddddc{iiii}iiicdddc{dddd}c{iiii}iiic{i}ddc{ddddd}dc{iii}iiiciic{ddd}dddddc{iii}iiiciiic{ddd}ddddddc{iii}iiic{i}dddc{dddd}c{iii}iiic{ii}ddc{ddddd}dc{ii}ddc{ii}dddc{ddd}dddddc{ii}ddc{ii}ddc{ddd}ddddddc{ii}ddc{ii}iic{dddd}c{ii}ddc{iii}iiic{ddddd}dc{ii}dc{i}iiiiiic{ddd}dddddc{ii}dc{ii}dddc{ddd}ddddddc{ii}dc{ii}ic{dddd}c{ii}dc{iii}iic{ddddd}dc{ii}c{i}iiiiic{ddd}dddddc{ii}c{i}iiiiiic{ddd}ddddddc{ii}c{ii}c{dddd}c{ii}c{iii}ic{ddddd}dc{ii}ic{i}iiiic{ddd}dddddc{ii}ic{i}iiiiic{ddd}ddddddc{ii}ic{ii}dc{dddd}c{ii}ic{iii}c{ddddd}dc{ii}iic{i}iiic{ddd}dddddc{ii}iic{i}iiiic{ddd}ddddddc{ii}iic{ii}ddc{dddd}c{ii}iic{iii}dc{ddddd}dc{ii}iiic{i}iic{ddd}dddddc{ii}iiic{i}iiic{ddd}ddddddc{ii}iiic{ii}dddc{dddd}c{ii}iiic{iii}ddc{ddddd}dc{ii}iiiic{i}ic{ddd}dddddc{ii}iiiic{i}iic{ddd}ddddddc{ii}iiiic{i}iiiiiic{dddd}c{ii}iiiic{iii}dddc{ddddd}dc{ii}iiiiic{i}c{ddd}dddddc{ii}iiiiic{i}ic{ddd}ddddddc{ii}iiiiic{i}iiiiic{dddd}c{ii}iiiiic{ii}iiiiiic{ddddd}dc{ii}dddcdc{ii}dc{ddd}dddddc{ii}dddcdc{ii}c{ddd}ddddddc{ii}dddcdc{ii}iiiic{dddd}c{ii}dddcdc{iii}iiiiic{ddddd}dc{iiii}iic{dddd}ddc{iiii}iic

Try it online!

This looks quite a lot longer than the generated text. Am I missing something?

@AJFaraday Deadfish~ is a very inconvenient lanugage. See the wiki

WHYYYYYYYYYYYYY!

Why not? I didn't write this by hand.

Vyxal, 24 bytes
₀ɾḢ«∧9₂«fJ«¬⟩C«Ẋvṅ‛jjfJɾ

Try it Online!
How?
₀ɾḢ«∧9₂«fJ«¬⟩C«Ẋvṅ‛jjfJɾ
₀ɾ                       # Push a list in the range [1, 10]
  Ḣ                      # Remove the first: [2, 3, 4, ..., 10]
   «∧9₂«                 # Push compressed string "jqka"
        fJ               # Convert to list of characters and add to the other list: [2, 3, 4, ..., 10, "j", "q", "k", "a"]
          «¬⟩C«           # Push compressed string "hsdc"
               Ẋ         # Cartesian product of list and string: [[2, "h"], [2, "s"], ..., ["a", "c"]]
                vṅ       # Join each together: ["2h", "2s", ..., "ac"]
                  ‛jjf   # Push string "jj" and convert to list of characters: ["j", "j"]
                      J  # Append: ["2h", "2s", ..., "ac", "j", "j"]
                       ɾ # Uppercase each: ["2H", "2S", ..., "AC", "J", "J"]

Haskell, 57 bytes
"J":"J":[c++[s]|c<-"10":map pure"AJQK23456789",s<-"SDHC"]

Try it online!

Retina, 49 42 bytes

AJQK2345678910
1?.
$0H,$0S,$0D,$0C,
$
J,J
Credit to @mazzy's comment on my Java answer.
-7 bytes thanks to @ovs.
Try it online.
Explanation:
Start with "AJQK2345678910":

AJQK2345678910
For each character (with "10" as single character):
Replace it with "cH,cS,cD,cC" where c is this character:
1?.
$0H,$0S,$0D,$0C,

And append "J,J"
$
J,J

You can shorten this by 4 bytes by removing capturing groups and replacing $1 with $&.

42 bytes

@ovs Thanks. Was about to remove the parenthesis at (1?.) and use $0, but the appending of J,J is certainly shorter. Figured it would be possible, but I don't golf that often in Retina, so didn't knew how to append and hadn't had to time to search in the docs more thoroughly. PS: What's the difference between $& and $0 in this case, if there is any?

It seems like there is no difference, but $& is used more often in the Retina docs, so I got used to it.

$& comes from Perl, where it is the string matched by the last successful pattern match. (In Perl 6, you would use $/ with the prefix stringification op ~ instead)

MATLAB R2018a, 82 57 bytes
Thanks to @David:
s=["A" 2:10 "J" "Q" "K"]+["D";"S";"H";"C"];[s(:);"J";"J"]

My old code:
X=["J","J"];for n=["A",2:10,"J","Q","K"]for s=["S","H","C","D"]X=[X,n+s];end;end;X

I figure it doesn't need an explanation but in case someone's interested:
X=["J","J"] // Set up first two Jokers
 for n=["A",2:10,"J","Q","K"] // Set up array for A, 2, 3... to K
  for s=["S","H","C","D"] // Set up suits
   X=[X,n+s]; // "Glue" value and suit together and add to array
  end
 end
X // Print out the result

Output:
X =
1×54 string array
Columns 1 through 11
"J"    "J"    "AS"    "AH"    "AC"    "AD"    "2S"    "2H"    "2C"    "2D"    "3S"

Columns 12 through 22
"3H"    "3C"    "3D"    "4S"    "4H"    "4C"    "4D"    "5S"    "5H"    "5C"    "5D"

Columns 23 through 33
"6S"    "6H"    "6C"    "6D"    "7S"    "7H"    "7C"    "7D"    "8S"    "8H"    "8C"

Columns 34 through 43
"8D"    "9S"    "9H"    "9C"    "9D"    "10S"    "10H"    "10C"    "10D"    "JS"

Columns 44 through 54
"JH"    "JC"    "JD"    "QS"    "QH"    "QC"    "QD"    "KS"    "KH"    "KC"    "KD"

+1, I didn't know about using " for strings! This can be shortened in newer version of Matlab (=>2016b) s=["A" 2:10 "J" "Q" "K"]+["D";"S";"H";"C"];[s(:);"J";"J"]

VBA + RegExp,  135 bytes
A declared function that takes no input and outputs to the out var, o.
This subroutine depends upon the Microsoft VBScript Regular Expression 5.5 reference.
Sub a(o)
Set r=New RegExp
r.Global=1
r.Pattern="(\w+)"
o=Split(r.Replace("A 2 3 4 5 6 7 8 9 10 J Q K","$1S $1H $1D $1C")&" J J")
End Sub

Note: The terminal " on line 4 is not counted in the bytecount as it is not necessary and is only included for SO's syntax highlighting

8th, 156 152 149 bytes
Code
[] ( >s a:push ) 2 10 loop ["J","Q","K","A"] a:+ ( nip dup ["C","D","S","H"] ( nip s:+ >r dup ) a:each drop ) a:each ["J","J"] ( r> a:push ) 52 times

Array result is available on TOS
Output
["J","J","AH","AS","AD","AC","KH","KS","KD","KC","QH","QS","QD","QC","JH","JS","JD","JC","10H","10S","10D","10C","9H","9S","9D","9C","8H","8S","8D","8C","7H","7S","7D","7C","6H","6S","6D","6C","5H","5S","5D","5C","4H","4S","4D","4C","3H","3S","3D","3C","2H","2S","2D","2C"]

Ungolfed code
\ make array ["2","3","4","5","6","7","8","9","10"]
[] ( >s a:push ) 2 10 loop

\ make array ["2","3","4","5","6","7","8","9","10","A","J","Q","K"]
["J","Q","K","A"] a:+

\ make 13 cards for each suit and store each card on r-stack
( nip dup ["C","D","S","H"] ( nip s:+ >r dup ) a:each drop ) a:each

\ make array result reading previous cards from r-stack
["J","J"] ( r> a:push ) 52 times

\ array result is available on TOS. Display it and get rid of intermediate stuff
. cr
reset

Gol><>, 46 44 bytes
"CDSH"4F:j9FL2+noao|j"AKQJ"4F$ooao||S"J`nJ";

Try it online!
Edit: Saved 2 bytes thanks to Jo King
Explanation:
"CDSH"4F:j9FL2+noao|j"AKQJ"4F$ooao||S"J`nJ";

"CDSH"                                        //Init the 4 suites
      4F                                      //Loop to iterate over the 4 suites
        :j                                    //Pop a copy of the current suite into the next loop
           9FL2+noao|                         //Loop for the output of cards 2-10
                    j                         //Pass current suite into next loop & pop it from the stack
                     "AKQJ"                   //Init the 4 pictures
                           4F$ooao|           //Loop 4 times to output the picture cards
                                   |          //Jump back to the for loop to iterate over all suites
                                    S"J`nJ";  //Output the two J and terminate programm

Bash (if Unicode is allowed), 45 bytes
echo -e \\U1F0{{A..D}{{1..9},{A..E}},{CF,DF}}

...produces:

Try it online!
This should work wherever Unicode is supported (ex: LANG=en_US.UTF8, not LANG=C). I'm not sure, however, if this meets the conditions of the rules. In particular:

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).

The Unicode answer has one string per element, and the images indeed show a value followed by a suit. The example output, however, shows two separate chars per element, so there's room for doubt.
If the Unicode approach is disallowed, the code can be easily trimmed down to 34 bytes:
d=({A,K,Q,J,{10..2}}{S,H,D,C} J J)

Try it online!
...but that is no shorter than the existing answer by glenn jackman (albeit sorted).
Regardless, Unicode is a technique worth mentioning. If you're dealing out a deck of cards, you might as well use the nice little images which are probably already on your computer, even in a text-mode terminal.
As for the question about the rules, I think the best answer is for someone to develop a question format which intrinsically includes an automated unit test. Maybe someday...

Welcome to the site.  Unlike other forums all answers must include a complete solution to the problem, and I think you are correct that this does not technically fit the specifications of the problem.  If you would like to add a complete solution to your answer you can do that (and keep your partial solution as a bonus) but without a complete solution answers are subject to deletion.

Anyways, the unicode solution you have it prints out the knight card.

C (gcc), 86 bytes
f(i){for(i=54;i--;)printf(i<52?"1%c%c "+(i>3):"J ","023456789JQKA"[i/4],"HSDC"[i%4]);}

Try it online!

MASM 5 MACRO (x86 machine code), 109 100 bytes
D LABEL BYTE
IRPC r,234567890JQKA
IRPC s,DSHC
IF'&r'EQ'0'
DB'1'
ENDIF
DB'&r','&s '
ENDM
ENDM
DB'J J'

Since machine code has no formal definition for "an array of variable length strings", this returns the elements as characters in contiguous memory, delimited by a separator byte (20H) with the label D as a pointer to the location in memory.
Obviously, this would all be a lot simpler and smaller (76 bytes) if we could use 'T' for 10, which would make all cards exactly 2 bytes in size and simply be an indexable array of DW (double-words). That's your Kolmogorov rub I suppose!
Here's a short test program that shows one possible way this could be utilized:
MOV  DX, OFFSET D
MOV  AH, 9
INT  21H
MOV  AH, 4CH
INT  21H

Output
2D 2S 2H 2C 3D 3S 3H 3C 4D 4S 4H 4C 5D 5S 5H 5C 6D 6S 6H 6C 7D 7S 7H 7C 8D 8S 8H 8C 9D 9S 9H 9C 10D 10S 10H 10C JD JS JH JC QD QS QH QC KD KS KH KC AD AS AH AC J J

Rockstar, 129 99 bytes
say "J
J"
cut "CHSD" in S
while S
roll S in X
say 10+X
cut "A23456789JQK" in V
while V
say roll V+X

Try it here (Code will need to be pasted in)
say "J\nJ"          :Output the jokers
cut "CHSD" in S     :Split "CHSD" into array S
while S             :While S is not empty
roll S in X         :  Pop the first element into variable X
say 10+X            :  Output 10 appended with X
cut "..." in V      :  Split "A23456789JQK" into array V
while V             :  While V is not empty
say                 :    Output
  roll V            :      Pop the first element from V
  +X                :      Append X

Factor + poker, 64 bytes
<deck> hand>card-names [ "T""10"replace ] map { "J""J"} append .

Try it online!
Factor has a poker vocabulary that gets most of the way there; just have to change T to 10 and add the jokers.

C# (.NET Core), 140 bytes
x=>{var a=new string[54];a[0]=a[1]="J";int i=2;foreach(var s in"SDCH")foreach(var n in"023456789AJQK")a[i++]=(n=='0'?"10":n+"")+s;return a;}

Try it online!
-10 bytes thanks to Kevin Cruijssen
-1 byte by taking unused input
-18 bytes thanks to Corak

You can remove the {} of the foreach, and .ToString() can be +"".

116 bytes by creating a port of my Java answer: o=>(new System.Text.RegularExpressions.Regex("(1?.)").Replace("AJQK2345678910","$1H,$1S,$1D,$1C,")+"J,J").Split(','). Credit to @mazzy's comment.

@KevinCruijssen huh, I thought I needed the {} because of the nested foreach. Thanks! I'm not going to use your java port given it's such a drastically different approach, I'll let you post that yourself. Also just realised I can take unused input to shave a byte

You should be able to remove both .ToCharArray() calls. A string is already an IEnumerable<char>

@Corak oh wow you're right!

I wonder if something could be done with new[]{"J","J"}.Concat(from s in "SDCH" from n in "023456789AJQK" select (n=='0'?"10":n+"")+s);, but the using alone would probably make it unpractical.

@Corak Oh nice. It's actually even shorter than the Regex-Replace I suggested above. 109 bytes to be exact, including the using System.Linq;.

@KevinCruijssen - I'm not familiar on how much "surrounding" code (header/footer) is allowed in code golf. So technically System.Collections.Generic needs to be counted, too, right? And technically the question asks for string[], so there would be an additional .ToArray() in there.

@Corak Ah, you're right the .ToArray() should be added for this particular challenge, in which case it's 119 bytes. But the System.Collections.Generic isn't necessary in this case. As you can see in the TIO I linked, with just the using System.Linq; it works, so only that one should be counted towards to byte-count.

I've posted it as a separated answer. If you wanted to post it yourself @Corak let me know, then I'll remove that part of my answer and will make sure to upvote you when you've posted it. :)

Red, 88 bytes
foreach s{HSDC}[foreach c['A 2 3 4 5 6 7 8 9 10 'J 'Q 'K][prin c print s]]prin['J"^/"'J]

Try it online!
As a list:
Red, 100 bytes
d:[]foreach s{HSDC}[foreach c['A 2 3 4 5 6 7 8 9 10 'J 'Q 'K][append d rejoin[c s]]]append d["J""J"]

Try it online!

CJam, 45 bytes
"A"]8,2f+'0f+"10"a+"JQK"++"SDHC"m*::+["J"_]+p

Try it online!

Jelly, 24 bytes
⁵ḊṾ€;“AJQK”p“HSDC”;⁾JJẎ€

Try it online!

JavaScript (Node.js), 126 bytes
[..."SDHC"].map(a=>Array.apply(0,Array(13)).map((b,i)=>(i==0?'A':i>9?'JQK'[i-10]:i+1)+a)).reduce((a,b)=>a.concat(b),['J','J'])

Try it online!

Stax, 21 bytes
Å|R╦¥Ä└╥¿‼≈┴2½#d☺Iwa▐

Run and debug it
Explanation:
9{^$m"AJQK"+"HSDC"|*'JQPm Full program, unpacked
                          Stack ([] is array, "" string '' char): empty
9{  m                     Map each element in range [1, 9]
  ^                         Increment
   $                        Stringify
                          Stack: ["2", "3", "4", "5", "6", "7", "8", "9", "10"]
     "AJQK"+              Add "AJQK"
                          Stack: ["2", "3", "4", "5", "6", "7", "8", "9", "10", 'A', 'J', 'Q', 'K']
            "HSDC"        Push suits
                          Stack: "HSDC" ["2", "3", "4", "5", "6", "7", "8", "9", "10", 'A', 'J', 'Q', 'K']
                  |*      Cartesian join
                          Stack: [["2", 'H'], ["2", 'S'], ..., "AH", "AS", ...]
                    'J    Push "J"
                          Stack: "J" [...]
                      Q   Peek and print with newline
                          Stack: "J" [...]
                       P  Pop and print with newline
                          Stack: [...]
                        m Map, implicitly print each with a newline

Although a nice solution, I'm afraid it's currently invalid. You're currently printing the cards newline-delimited to STDOUT, but it should be output as a single list. It's currently hidden in the comments (see this comment - and the ones it's replying to, and this comment - including the one above it), so I can understand that you've missed it..

Twig, 83 82 bytes
J J{%for I in(2..9)|merge('AKQJ'|split)%} {{I~'SDHC'|split|join(' '~I)}}{%endfor%}

This outputs the suits grouped by the "number".
You can test it on: https://twigfiddle.com/lz9cuf
Old version:

https://twigfiddle.com/jmkyza (83 bytes)
The output has a trailing space

SimpleTemplate, 69 bytes
This is a template-like language I've been developing, all written in PHP.
The instructions on how to use it are available in the Github page.
J J{@setx"SDHC","23456789JQKA"}{@eachx.1 asN}{@eachx.0}{@echo" ",N,_}

Ungolfed:
J J
{@set chars "SDHC", "23456789JQKA"}
{@each chars.1 as number}
    {@each chars.0 suite}
        {@echo " ", number, suite}
    {@/}
{@/}

Due to a series of bugs, this is not the most optimal solution. A shorter (non-working but should work) version below (51 bytes):
J J{@each"23456789JQKA"asN}{@each"SDHC"} {@echoN,_}

This, however, doesn't work.

vim, 80 bytes
aoA J Q K<C-V><ESC>:r !seq 2 10<C-V><CR>o<C-V><ESC>V10kJ:s/ /H /g<ESC>
yy3P34lrSjrDjrC:g/./:norm dd@"
oJ J<ESC>

<C-V> is 0x16. <CR> is 0x0d. <ESC> is 0x1B
Annotated
a                                    " insert vim code into the buffer that:
   oA J Q K<C-V><ESC>                "   generates face cards
   :r !seq 2 10<C-V><CR>o<C-V><ESC>  "   generates 2-10
   V10kJ                             "   joins into one line
   :s/ /H /g<ESC>                    "   adds suit (hearts)
yy3P                                 " make 3 copies of code
34lrSjrDjrC                          " change suit for each copy
:g/./:norm dd@"              " replace each line with the results from running it
o J J<ESC>                   " Jokers

Try it online!

Google Sheets, 86 Bytes
A worksheet function that returns an array of "cards" to the the calling cell and the 53 cells to its right.
=Split(RegExReplace("A 2 3 4 5 6 7 8 9 10 J Q K","(\w+)","$1S $1H $1D $1C ")&" J J","

Note: This function ends with a trailing space

Yabasic, 123 bytes
Dim r$(54)
r$(1)="J"
r$(2)="J"
For i=0To 51
r$(i+3)=Mid$("JQKA2345678910",1+i/4,1+(i/4>=12))+Mid$("CDHS",Mod(i,4)+1,1)
Next

Try it online!

Cjam, 29 26 bytes
B,2>"AJQK"+"SDHC"m*"JJ"+N*

Try it online!
Explanation:
B,2>        e# Generate the range [2, 10]
"AJQK"+     e# add the list with "AJQK"
            e# which generates all the 13 cards
"SDHC"      e# Push the variants
m*          e# Cartesian product
"JJ"+       e# Add 2 J's to the list
N*          e# And join the list items with newlines

Note:

The previous count was incorrect; it should be 29 instead of 28.
The challenge said the order doesn't matter, so 3 bytes off!

Julia, 63 bytes
[["1"^(k<'1')*"$k$z"for k="A234567890JQK"for z="HSDC"];"J";"J"]

Explanation
[
    [
        "1"^(k<'1')           # "1" if k is lexicographically before '1'
                              # which here only happens if k is '0'
        *"$k$z"               # concatenated to k and z
        for k="A234567890JQK" # for k in ranks
        for z="HSDC"          # and z in suits
    ]
    ;"J"                      # then concatenate 2 jokers
    ;"J"
]

Groovy,  68 66 60 bytes
This is my first stab at a golf challenge, hope I get everything right.
68 byte version

[*2..10,*'AKQJ'.grep()].collectMany{n->'HSDC'.collect{n+it}}+['J']*2

Try it here

66 byte version

[*2..10,*'AKQJ'.grep()].inject([]){a,e->a+'HSDC'*.plus(e)}+['J']*2

Try it here

60 byte version

'HSDC'.grep().sum{[*2..10,*'AKQJ'.grep()]*.plus(it)}+['J']*2

Try it here

Welcome to Code Golf! Nice work! One thing, tho, it's usually preferable to add a link to an online interpreter so folks can verify your solution works. Here's one for your solution: https://groovyconsole.appspot.com/script/5194941521199104 (You might like to add that to your answer).

Plain TeX, 348 bytes
It's just text printed as if it were an array, but that is close enough I think. It's not like TeX has native arrays anyway (although I do use some form of arrays in the code).
Short answer:
\newcount\i\let\c\csname\let\e\endcsname\let\t\the\def~#1,#2,#3{\expandafter\def\c#2\t#1\e{#3}}\i3 ~\i,a,K~\i,s,D\i4 ~\i,a,Q~\i,s,C\i5 ~\i,a,J~\i,s,S\i2 ~\i,a,A~\i,s,H\newcount\v[\loop\v2{\loop"\t\v\c s\t\i\e", \ifnum\v<10\advance\v1\repeat}{\loop"\c a\t\v\e\c s\t\i\e", \ifnum\v<5\advance\v1\repeat}\break\ifnum\i<5\advance\i1\repeat "J", "J"]\bye

Long answer, with comments as explanation:
%First shorten some commands
\let\c\csname
\let\e\endcsname
\let\t\the
%then define the function todefine and fill the arrays
\def ~#1,#2,#3{\expandafter\def\c #2\t#1\e{#3}}
%main counter in this program
\newcount\i
\i3
%array a contains A, K, Q, J, the 'picture cards'
%array s contains D, C, S, H, the suits
%indexing is 2 to 5 so the same counter as for the 2...10 can be used
 ~\i,a,K
 ~\i,s,D
\i4
 ~\i,a,Q
 ~\i,s,C
\i5
 ~\i,a,J
 ~\i,s,S
%2 is the last one as we want i to be 2 after this
\i2
 ~\i,a,A
 ~\i,s,H
%the other counter
\newcount\v
%outer loop loops over the suits
[\loop
    %2 is the starting point for the arrays and the numbers
    \v2
    %brackets to ensure local use of \v
    %first loop iterates over the numbers
    {
     \loop
     %this prints v and the current suit
     "\t\v \c s\t\i\e",
     \ifnum\v<10
        %\advance \v by 1
        \advance\v1
     \repeat
    }
    %...second loop over the picture cards
    {
     \loop
     "\c a\t\v\e \c s\t\i\e",
     \ifnum\v<5
        \advance\v1
     \repeat
    }
    %to prevent the output escaping the file on the right border
    \break
    \ifnum\i<5
        \advance\i1
 \repeat
 %then print the jokers
 "J", "J"
]
\bye

Pyth - 32 bytes
K+r2hTc"JQKA"1\J\JJ"SDHC"VJVK+HN

Explanation:
K+r2hTc"JQKA"1\J\JJ"SDHC"VJVK+HN
K                                 Assign variable K to
  r2hT                            Range from 2 to 10 plus 1
 +                                Plus
      c"JQKA"1                    Length 1 substrings of "JQKA"

              \J\J                Print 1 character string "J" twice

                  J"SDHC"         Assign J to "SDHC"

                         VJ       For N in J
                           VK     For H in K
                             +HN  Implicitly print H+N

PicoLisp, 181 171 bytes
(replaced ifn with if)
(setq c '(A 2 3 4 5 6 7 8 9 10 J Q K))
(de z (s l)(if (<> l NIL) (cons (pack (car l) s) (z s (cdr l)))))
(setq d (conc (z 'C c) (z 'D c) (z 'H c) (z 'S c) (list "J" "J")))

Sample output:
bash$ pil +
: (load 'cards.l)
-> ("AC" "2C" "3C" "4C" "5C" "6C" "7C" "8C" "9C" "10C" "JC" "QC" "KC" "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" "AS" "2S" "3S" "4S" "5S" "6S" "7S" "8S" "9S" "10S" "JS" "QS" "KS" "J" "J")
: d
-> ("AC" "2C" "3C" "4C" "5C" "6C" "7C" "8C" "9C" "10C" "JC" "QC" "KC" "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" "AS" "2S" "3S" "4S" "5S" "6S" "7S" "8S" "9S" "10S" "JS" "QS" "KS" "J" "J")
:

Try it online!

C (gcc), 129 bytes
char*v[]={"A","2","3","4","5","6","7","8","9","10","J","Q","K"};main(i){for(i=0;i<13;)printf("%sS %1$sD %1$sH %1$sC ",v[i++]);puts("J J");}

C (gcc), 89 bytes
main(i){for(i=0;i<13;)printf("%cS %1$cD %1$cH %1$cC ","A23456789XJQK"[i++]);puts("J J");}

2018-09-16: -12 @gastropner

You can forgo declaring v and index into the literal to shave some bytes off.

Suggest i=13;i--; instead of i=0;i<13; and ,"KQJX98765432A"[i] instead of "A23456789XJQK"[i++]

@ceilingcat what stops the loop?

@Blacksilver the loop stops when i--==0

Brain-Flak, 276 bytes
((((((((()()())){}{})())[][])<>()())(<()>))<>[][][]){(<>)((((([()()()])){}{})[()])()){(({}<>(<(({})<>)>)()))}{}{}(((((()()()){}())(<<>(({})<>)>)((()()())){}{})(<<>(({})<>)>)())(<<>(({})<>)>)(()()()){})<>({}<>)<>}<>{{({}((((()()()){}()){}){}()){}<>)<>}{}<>((()()()()()){})<>}<>

Try it online!
Prints each card on its own line, with a leading newline.
Explanation:
((((((
((()()())){}{})  # Push 9 to represent  'C'
())              # Push 10 to represent 'D'
[][])            # Push 14 to represent 'H'
<>()())(<()>))   # Push 16, 0, 16 to the other stack to represent the Jokers
<>[][][])        # Push 25 to represent 'S'
{  # Loop over each suit
  (<>)  # Push 0 for a newline
  ((
    ((([()()()])){}{})  # Push -9 to represent '1'
    [()])               # Push -10 to represent '0'
  ())   # Push -9 to use as a counter
  {  # Loop 9 times to push the number cards
    (({}  # Store counter
     <>(<(({})<>)>)  #Push current suit and newline
    ()))  # Decrement counter and push twice, once as the number
  }{}{}
  ((((
    (()()()){}())  # Push 7 as 'A'
    (<<>(({})<>)>) # Push suit and newline
    ((()()())){}{})# Push 16 as 'J'
    (<<>(({})<>)>) # Push suit and newline
    ())            # Push 17 as 'K'
    (<<>(({})<>)>) # Push suit and newline
    (()()()){})    # Push 23 as 'Q'
  <>({}<>)<>       # Push suit
}
<>
{  # Loop over all output
  {  # Add 58 to each number
    ({}((((()()()){}()){}){}()){}<>)<>
  }
  {}<>((()()()()()){})<>  # And turn 0s into newlines
}<>  # Implicit output

Kotlin, 76 bytes
("A2345678910JQK".replace(Regex("1?."),"$0C $0D $0H $0S ")+"J J").split(" ")

Try it online!

Tcl, 76 bytes
lmap n {S C H D} {lmap v {A K Q J 2 3 4 5 6 7 8 9 10} {puts $v$n}}
puts J\nJ

Try it online!

Pyth, 30 29 31 bytes
Current
+,K\JKsM*+tST[\AK\Q\K)[\H\D\C\S

Previous:
+,K\JK*+tST[\AK\Q\K)[\H\D\C\S
+,K\JK*+tS10[\AK\Q\K)[\H\D\C\S

Explanation:
+,K\JKsM*+tS10[\AK\Q\K)[\H\D\C\S
 ,K\JK                              Create a tuple ('J', 'J'), meanwhile assign 'J' to K
         +tS10[\AK\Q\K)             Create a range from 2-10 and append [A, J, Q, K] (K = 'J')
                       [\H\D\C\S    Create range [H, D, C, S]
      sM*                           Get the Cartesian product of {Num Range} & {Suit Range}, then join them as a string
+                                   Join the jokers onto the result.

Try it online!

PostScript, 90 84 bytes
Output as an array of strings on the stack.
00000000: 5b28 4443 4853 297b 2f64 923e 9233 284a  [(DCHS){/d.>.3(J
00000010: 514b 4132 3334 3536 3738 3929 7b2f 6a92  QKA23456789){/j.
00000020: 3e92 3332 92a5 9238 9238 3020 6a92 7831  >.32...8.80 j.x1
00000030: 2064 9278 7d92 497d 9249 2831 3044 2928   d.x}.I}.I(10D)(
00000040: 3130 4329 2831 3048 2928 3130 5329 284a  10C)(10H)(10S)(J
00000050: 2992 385d                                ).8]

Pre-tokenization (119 bytes):
[(DCHS){/d exch def(JQKA23456789){/j exch def 2 string dup dup 0 j put 1 d put}forall}forall(10D)(10C)(10H)(10S)(J)dup]

Try it online! (Pre-tokenized version as I don't know how to paste the tokenized file into TIO.)