Score an asynchronous prisoner's dilemma game In a round of the prisoner's dilemma exercise, two players each decide whether to cooperate or defect for that round. The scoring for a round is:


Player A and Player B both cooperate: 1 point for both
Player A and Player B both defect: 2 points for both
Player A cooperates and Player B defects: 3 points for cooperating Player A and 0 points for defecting Player B


You don't need to worry about strategy, though: your program will merely be tabulating the score for a game. (In case you are already familiar with prisoner's dilemma, my "points" here correspond to "years in prison.")

Your challenge is to take input that represents the players' choices over several rounds and compute their respective total scores. One player submits choices in lowercase, c and d (for cooperate and defect), and the other submits choices in uppercase, C and D. These choices are supplied to your program as a string.

Normally, players in prisoner's dilemma submit their moves simultaneously and iteratively. In this challenge, however, the players may have submitted their choices for several rounds at once. If a player's move is out of sequence, the scoring program remembers it and matches it with the next available move from the opposing player.

Here's a sample input string:

cDCddDDCcCc


To show the matches that exist in this input, I'll call out the lowercase and uppercase separately, and pair them up:

cDCddDDCcCc
c  dd   c c =&gt; cddcc
 DC  DDC C  =&gt; DCDDCC


These will be paired into the rounds:

c vs D (3 pts for lowercase-player, 0 pts for uppercase-player)
d vs C (0 pts for lowercase-player, 3 pts for uppercase-player)
d vs D (2 pts for both)
c vs D (3 pts for lowercase-player, 0 pts for uppercase-player)
c vs C (1 pt for both)


Which produces the score 9 (lowercase) to 6 (uppercase), so the output should be 9,6 (or any unambiguous delimiter).

To express it in yet another way, here's each pairing pulled out on its own row:

cDCddDDCcCc
cD
  Cd
    dD
      D c
       C  c


There is one unmatched C, because the uppercase player submitted more moves than the lowercase player. That is acceptable, and it is totally ignored for scoring purposes.

Here are the requirements:


You must write a program or function that accepts a string of the regular-expression form /[cdCD]+/, through some input mechanism (STDIN, function argument, read from file, etc.). (Your program may optionally accept input with a trailing newline.)
Your program or function must output or return the players' scores as a string. The output format must start with the lowercase player's score, followed by the uppercase player's score, separated by any non-empty, non-numeric delimiter of your choice. (A trailing newline is optional.)
If one player has more moves than the other, the excess moves are ignored.
If all moves in the input are from exclusively one player (that is, no rounds have been played at all), then each player's score is 0.
The smallest submission in bytes wins.


Test cases

Input:  cDCddDDCcCc
Output: 9,6         -- or any delimiter; I chose commas here

Input:  cccDDD
Output: 9,0         

Input:  DDDDDDccc
Output: 9,0

Input:  cDcDcD
Output: 9,0

Input:  dcDDC
Output: 5,2

Input:  CcdCDDcd
Output: 6,6

Input:  Ddd
Output: 2,2

Input:  ccccccccccc
Output: 0,0
Haskell, 139 134 bytes

g=filter
(n!m)(a,b)=(a+n,b+m)
f s=init$tail$show$foldr id(0,0)$zipWith(#)(g(&gt;'a')s)$g(&lt;'E')s
'c'# 'C'=1!1
'c'#_=3!0
_# 'D'=2!2
_#_=0!3


Usage example: f "cDCddDDCcCc" ->  "9,6"

15 bytes just to get the output format right, i.e. turning a pair of numbers (x,y) into a string "x,y".

How it works:

               g(&gt;'a')s        -- extract all lowercase letters
                     g(&lt;'E')s  -- extract all uppercase letters
         zipWith(#)            -- combine both lists element wise with function #
                               -- # calls ! depending on the combination of c/d/C/D
                               -- ! takes 2 numbers a and b and returns a function
                               -- that takes a pair (x,y) and returns (x+a,y+b)
                               -- now we have a list of such functions
    foldr id(0,0)              -- apply those functions starting with (0,0)
init$tail$show                 -- format output                    


Edit: @Zgarb helped me saving 5 bytes. Thanks!