function [score deviation] = CCV(algo, X, y, type)

if(~exist('type','var'))
    type = 'short';
end

if strcmp(type,'one')
    Xtrain = X(1:9100,:);
    ytrain = y(1:9100,:);
    Xval = X(9101:end,:);
    yval = y(9101:end,:);

    ypred = algo(Xtrain,ytrain,Xval);

    score = validate(yval,ypred);
    deviation = 0;
    
    return;
    
elseif strcmp(type,'short')
    scores = zeros(5,1);
    for i=1:5
        I = 1:10000;
        Ival = 2000*(i-1) + (1:2000);
        Itrain = setdiff(I,Ival);
        
        if ~isequal(sort([Ival Itrain]),sort(unique([Ival Itrain])))
            error('WTF? o.O');
        end

        Xtrain = X(Itrain,:);
        ytrain = y(Itrain,:);
        Xval = X(Ival,:);
        yval = y(Ival,:);

        ypred = algo(Xtrain,ytrain,Xval);

        scores(i) = validate(yval,ypred);

        %fprintf('%d/5\n',i);
    end
    
else
    scores = zeros(10,1);
    for i=1:10
        I = 1:10000;
        Ival = 1000*(i-1) + (1:1000);
        Itrain = setdiff(I,Ival);

        Xtrain = X(Itrain,:);
        ytrain = y(Itrain,:);
        Xval = X(Ival,:);
        yval = y(Ival,:);

        ypred = algo(Xtrain,ytrain,Xval);

        scores(i) = validate(yval,ypred);

        %fprintf('%d/5\n',i);
    end
end

score = mean(scores);
deviation = std(scores);
fprintf('%.3f ± %.3f\n',score,deviation);

end
