function [p mz] = assignment(observed,correct)
    
    % matice zamen
    mz=zeros(3,3);
    for o=1:3        
        for c=1:3
            mz(o,c)=sum((observed==o)&(correct==c));
        end
    end

    % najdi vsechna mozna oznaceni shluku a ziskej pocty spatne prirazenych
    % pozorovani
    p=perms([1 2 3]);
    s=size(observed,1);
    inc_assigned=zeros(6,1);

    for i=1:6
       c1=mz(p(i,1),1);
       c2=mz(p(i,2),2);
       c3=mz(p(i,3),3);
       inc_assigned(i)=s-sum([c1 c2 c3]);
    end

    inc_min=min(inc_assigned);
    % spatne prirazenych pozorovani
    p=(100/s)*inc_min;
end