close all;
clear all;

for k = 1:6
    %Load file, find out number of flips
    load(sprintf('sequence%u.mat', k)); 
    N = length(test_sequence);
    x = test_sequence;


    count = 0; %initialize counter

    %Total number of Heads
    for h = 1:N  
       if x(h) == 1
           count = count + 1;
       end
    end

    heads = count/N
    count = 0;
    
    %Number of 2 heads in a row
    for h = 1:N-1
       if x(h) == x(h+1) && x(h) == 1
           count = count + 1;
       end
    end

    p2 = count/N
    count = 0;

    %Number of 3 heads in a row
    for h = 1:N - 2
       if x(h) == x(h+2) && x(h) == x(h+1) && x(h) == 1
           count = count +1;
       end
    end

    p3 = count/N
    count = 0;

    %Number of 4 heads in a row
    for h = 1: N-3
       if x(h) == x(h+3) && x(h) == x(h+2) && x(h) == x(h+1) && x(h) ==1
           count = count +1;   
       end
    end

    p4 = count/N
    count = 0;

    %Number of 5 heads in a row
    for h = 1: N-4
        if x(h) == x(h+4) && x(h) == x(h+3) && x(h) == x(h+2) && x(h) == x(h+1) && x(h) ==1
           count = count +1; 
        end
    end 

    p5 = count/N
    count = 0;
    
    %%Let's plot to see who's cheating
    %figure
    subplot(2,3,k);
    hold on
    results = [heads p2 p3 p4 p5];
    bar(results);
    xlabel('Number of heads in a row');
    ylabel('Probability');
    title(sprintf('Company number %u', k));
   
    hold off
    
end
