it should show answer of -30,why it show -10?what is wrong?
x=[33,11,33,11,22,33,11];r4penalty=0;r3penalty=0;r2penalty=0;r1penalty=0;penalty=0;for ii = 1:size(x,1) c = 1; Y = x(ii,:)==33; while c <= length(x)-1 if Y(c) if x(ii,c+1)==11 r4penalty=-10; c= c + 1; elseif Y(c+1:c+2) % Three in a row. (33,33,33)
r3penalty=-30; c = c + 4; elseif x(ii,c+1)==33 % Two in a row.(33,33,11)
r2penalty=-20; c = c + 3; elseif x(ii,c+1)==11 % Just one 33. (33,11)
r1penalty=-10; c = c + 2; elseif x(ii,c+1)==22 % pattern 33,22
c = c + 1; end else c = c + 1; end end penalty(ii,1)=r1penalty+r2penalty+r3penalty+r4penaltyend
did somebody know?
Best Answer