Code covered by the BSD License  

Highlights from
Cribbage Suite

image thumbnail
from Cribbage Suite by Bryan
Cribbage Suite is a GUI interface designed to help teach and play the game of cribbage.

isContinuous(array)
function ans = isContinuous(array)
%Used in the score5 function, isContinuous finds if the cards have any gaps
%in them.

array = sort(array); %Sort the array, lowest to highest.

ans = 1; %Assume true unless a gap is found.

for i = 2:length(array)
    gap = array(i) - array(i-1); %Find the difference between every number.
    if (gap > 1) || (gap == 0) %If the cards are split or if there are repeats
        ans = 0; %The answer is false
    end
end

Contact us at files@mathworks.com