proc shuffle . a[] .
   for i = len a[] downto 2
      r = random i
      swap a[r] a[i]
   .
.
func$ a2str a[] .
   for v in a[]
      r$ &= strchar v & " "
   .
   return r$
.
R = strcode "R"
B = strcode "B"
for i to 26
   pack[] &= R
   pack[] &= B
.
shuffle pack[]
# 
for i = 1 step 2 to 51
   if pack[i] = B
      black[] &= pack[i + 1]
   else
      red[] &= pack[i + 1]
   .
   discard[] &= pack[i]
.
print "After dealing the cards the state of the stacks is:"
print "  Red    : " & a2str red[]
print "  Black  : " & a2str black[]
print "  Discard: " & a2str discard[]
for i to len red[]
   rp[] &= i
.
for i to len black[]
   bp[] &= i
.
shuffle rp[]
shuffle bp[]
n = random lower len red[] len black[]
len rp[] n
len bp[] n
# 
for i to n
   h = red[rp[i]]
   red[rp[i]] = black[bp[i]]
   black[bp[i]] = h
.
print ""
print "After swapping " & n & " cards the state of the stacks is:"
print "  Red    : " & a2str red[]
print "  Black  : " & a2str black[]
# 
for c in red[]
   red += if c = R
.
for c in black[]
   black += if c = B
.
print ""
print "The number of red cards in the red stack     = " & red
print "The number of black cards in the black stack = " & black
if red = black
   print "So the asssertion is correct!"
.
