clc;
clear;
k=3;

D={[0 inf inf],[1 inf inf],[inf inf inf],[inf inf inf];
    [2 4 inf],[0 inf inf],[-1 inf inf],[inf inf inf];
    [2 inf inf],[inf inf inf],[0 inf inf],[-1 inf inf];
    [inf inf inf],[3 inf inf],[2 inf inf],[0 inf inf]};

for i=1:4
    for j=1:4
        if i>=j
            U{i,j}=[inf inf inf];
        else
            U{i,j}=D{i,j};
        end
    end
end

for i=1:4
    for j=1:4
        if i<=j
            L{i,j}=[inf inf inf];
        else
            L{i,j}=D{i,j};
        end
    end
end

gg=10;
i=1;
for a=1:4
    for b=1:4
        d{i,a,b}=D{a,b};
    end
end
f=d;
while gg==10
i=i+1;
l=1;
out1=kamnie(l,i,f,L,D,k);
d{i,1,4}=out1;
f{i,1,4}=d{i,1,4};
l=l+1;
out2=kamnie(l,i,f,L,D,k);
d{i,1,3}=out2;
f{i,1,3}=d{i,1,3};
l=l+1;
out3=kamnie(l,i,f,L,D,k);
d{i,1,2}=out3;
f{i,1,2}=d{i,1,2};
l=l+1;
out4=kamnie(l,i,f,L,D,k);
d{i,1,1}=out4;
f{i,1,1}=d{i,1,1};

i=i+1;
l=l+1;
out5=kamnie2(l,i,f,U,D,k);
d{i,1,1}=out5;
f{i,1,1}=d{i,1,1};
l=l+1;
out6=kamnie2(l,i,f,U,D,k);
d{i,1,2}=out6;
f{i,1,2}=d{i,1,2};
l=l+1;
out7=kamnie2(l,i,f,U,D,k);
d{i,1,3}=out7;
f{i,1,3}=d{i,1,3};
l=l+1;
out8=kamnie2(l,i,f,U,D,k);
d{i,1,4}=out8;
f{i,1,4}=d{i,1,4};

SC=Maxx(out1,out2,out3,out4,out5,out6,out7,out8);

if SC==4;
    disp('No. of Iter');disp(i-2);
    disp('d11=');disp(out4);
    disp('d12=');disp(out3);
    disp('d13=');disp(out2);
    disp('d14=');disp(out1);
    break
end

end
