function [next_facedownnums, next_facedownsuits] = ...
  ProbComb5CardGameNextHand(faceupnums, faceupsuits, ...
                            facedownleftnums,facedownleftsuits, ...
                            facedownnum, facedownsuit, ...
                            facedownrightnum, facedownrightsuit)
% [next_facedownnums, next_facedownsuits] = ...
% ProbComb5CardGameNextHand(islastcard, faceupnums, faceupsuits, ...
%                           facedownleftnums, facedownleftsuits, ...
%                           facedownnum, facedownsuit, ...
%                           facedownrightnum, facedownrightsuit)
%
% Find next possible hand in 5-card game (5 #'s, 4 suits)
%
% Outputs:
%  next_facedownnums = next hands' face-down numbers
%  next_facedownsuits = next hands' face-down suits
% Inputs:
%  faceupnums = face-up cards' #'s that cannot be in rest of hand
%  faceupsuits = face-up cards' suits that cannot be in rest of hand
%  facedownleftnums = #'s of cards in hands to left and known
%  facedownleftsuits = suits's of cards in hands to left and known
%  facedownnum = # of card to be incremented
%  facedownsuit = suit of card to be incremented
%  facedownrightnum = # on card to right of card incremented
%  facedownrightsuit = suit of card to right of card incremented
%
% return [0,0] when at end of all hands
%
% Order cards as follows:
%  face-up cards on left
%  face-down cards on left selected and not being incremented next
%    The above two are put together in excludenums and excludesuits
%  face-down card to be incremented
%  face-down card to right of incremented card being reset to first possible card
% (Re-order all the cards into two hands of three cards after next hand selected.
%
% Think of having an index indicating which face-down card is to be incremented.
%  Call this the inc_card.  Ignore cards to the right of the inc_card until the inc_card
%  is incremented. (So index not needed; it points to last card.)
% Increment the inc_card and reset next card to right of inc_card (if any) to
%  first card not already used in hand to the left.
%
% If inc_card is at end of deck after incrementing inc_card, move the inc_card
%  index one position left and recursively call this function, unless no more cards
%  to left, in which case return [0,0].
% If recursive call to this function returns [0,0], return [0,0].


% If past end of hands, set card # and suit to 0's.

  % If input is [0,0] return [0,0].
  if cardnum == 0 & suit == 0
    next_cardnum = 0;
    next_suit = 0;
  else
    next_cardnum = cardnum;
    next_suit = suit + 1;

    if next_suit == 5
      % Done with suits, reset suit and increment card number.
      next_suit = 1;
      next_cardnum = next_cardnum + 1;
      if next_cardnum == 6
        % Past end of card deck.  Set card # and suit to indicate error.
        next_cardnum = 0;
        next_suit = 0;
      end  
    end
end

