Cody

Solution 1810701

Submitted on 9 May 2019 by William
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
for i=1:1000 status=[10,10,10]; while sum(status)~=0 [Row_number, Num_of_lines] = remove_lines(status); if Num_of_lines>status(Row_number) disp('Error: Check number of lines'); result=false; break; end if Num_of_lines<1 disp('Error: You must remove at least one line'); result=false; break; end if Row_number~=1 && Row_number~=2 && Row_number~=3 disp('Error: Row number must be 1, 2 or 3.'); result=false; break; end if numel(Row_number)~=1 || numel(Num_of_lines)~=1 disp('Error: Row number must have one element'); result=false; break; end status(Row_number)=status(Row_number)-Num_of_lines; if sum(status)==0 disp('You lose'); result=false; break; end if sum(status)==1 disp('You win'); result=true; break; end [~,L]=max(status); status(L)=status(L)-randi(status(L)); if sum(status)==0 disp('You win'); result=true; break; end end res(i)=result; end number_of_wins= sum(res) assert(isequal(sum(res),1000))

status = 10 10 10 status = 0 6 10 status = 0 2 6 status = 0 0 2 You win status = 10 10 10 status = 0 3 10 status = 0 2 3 status = 0 1 2 You win status = 10 10 10 status = 0 6 10 status = 0 4 6 status = 0 2 4 status = 0 0 2 You win status = 10 10 10 status = 0 0 10 You win status = 10 10 10 status = 0 9 10 status = 0 0 9 You win status = 10 10 10 status = 0 5 10 status = 0 0 5 You win status = 10 10 10 status = 0 0 10 You win status = 10 10 10 status = 0 9 10 status = 0 5 9 status = 0 3 5 status = 0 0 3 You win status = 10 10 10 status = 0 0 10 You win status = 10 10 10 status = 0 3 10 status = 0 2 3 status = 0 1 2 You win status = 10 10 10 status = 0 0 10 You win status = 10 10 10 status = 0 5 10 status = 0 3 5 status = 0 0 3 You win status = 10 10 10 status = 0 5 10 status = 0 1 5 You win status = 10 10 10 status = 0 8 10 status = 0 7 8 status = 0 6 7 status = 0 0 6 You win status = 10 10 10 status = 0 0 10 You win status = 10 10 10 status = 0 7 10 status = 0 5 7 status = 0 0 5 You win status = 10 10 10 status = 0 4 10 status = 0 2 4 status = 0 1 2 You win status = 10 10 10 status = 0 8 10 status = 0 5 8 status = 0 0 5 You win status = 10 10 10 status = 0 3 10 status = 0 2 3 status = 0 1 2 You win status = 10 10 10 status = 0 0 10 You win status = 10 10 10 status = 0 3 10 status = 0 2 3 status = 0 1 2 You win status = 10 10 10 status = 0 7 10 status = 0 2 7 status = 0 0 2 You win status = 10 10 10 status = 0 4 10 status = 0 1 4 You win status = 10 10 10 status = 0 4 10 status = 0 1 4 You win status = 10 10 10 status = 0 3 10 status = 0 0 3 You win status = 10 10 10 status = 0 5 10 status = 0 0 5 You win status = 10 10 10 status = 0 8 10 status = 0 0 8 You win status = 10 10 10 status = 0 7 10 status = 0 5 7 status = 0 0 5 You win status = 10 10 10 status = 0 6 10 status = 0 3 6 status = 0 2 3 status = 0 1 2 You win status = 10 10 10 status = 0 5 10 status = 0 2 5 status = 0 0 2 You win status = 10 10 10 status = 0 5 10 status = 0 3 5 status = 0 2 3 status = 0 1 2 You win status = 10 10 10 status = 0 0 10 You win status = 10 10 10 status = 0 1 10 You win status = 10 10 10 status = 0 9 10 status = 0 2 9 status = 0 0 2 You win status = 10 10 10 status = 0 8 10 status = 0 7 8 status = 0 1 7 You win status = 10 10 10 status = 0 8 10 status = 0 2 8 status = 0 1 2 You win status = 10 10 10 status = 0 1 10 You win status = 10 10 10 status = 0 4 10 status = 0 2 4 status = 0 1 2 You win status = 10 10 10 status = 0 3 10 status = 0 2 3 status = 0 0 2 You win status = 10 10 10 status = 0 4 10 status = 0 3 4 status = 0 1 3 You win status = 10 10 10 status = 0 2 10 status = 0 0 2 You win status = 10 10 10 status = 0 5 10 status = 0 2 5 status = 0 0 2 You win status = 10 10 10 status = 0 9 10 status = 0 2 9 status = 0 1 2 You win status = 10 10 10 status = 0 9 10 status = 0 2 9 status = 0 0 2 You win status = 10 10 10 status = 0 2 10 status = 0 1 2 You win status = 10 10 10 status = 0 9 10 status = 0 6 9 status = 0 0 6 You win status = 10 10 10 status = 0 6 10 status = 0 1 6 You win status = 10 10 10 status = 0 2 10 status = 0 1 2 You win status = 10 10 10 status = 0 2 10 status = 0 0 2 You win status = 10 10 10 status = 0 1 10 You win status = 10 10 10 status = 0 1 10 You win status = 10 10 10 status = 0 5 10 status = 0 2 5 status = 0 1 2 You win status = 10 10 10 status = 0 3 10 status = 0 2 3 status = 0 1 2 You win status = 10 10 10 status = 0 1 10 You win status = 10 10 10 status = 0 2 10 status = 0 0 2 You win status = 10 10 10 status = 0 9 10 status = 0 6 9 status = 0 2 6 status = 0 0 2 You win status = 10 10 10 status = 0 5 10 status = 0 4 5 status = 0 0 4 You win status = 10 10 10 status = 0 9 10 status = 0 4 9 status = 0 1 4 You win status = 10 10 10 status = 0 3 10 status = 0 2 3 status = 0 0 2 You win status = 10 10 10 status = 0 3 10 status = 0 0 3 You win status = 10 10 10 status = 0 0 10 You win status = 10 10 10 status = 0 0 10 You win status = 10 10 10 status = 0 2 10 status = 0 1 2 You win status = 10 10 10 status = 0 2 10 status = 0 1 2 You win status = 10 10 10 status = 0 1 10 You win status = 10 10 10 status = 0 3 10 status = 0 2 3 status = 0 1 2 You win status = 10 10 10 status = 0 7 10 status = 0 0 7 You win status = 10 10 10 status = 0 2 10 status = 0 0 2 You win status = 10 10 10 status = 0 0 10 You win status = 10 10 10 status = 0 3 10 status = 0 0 3 You win status = 10 10 10 status = 0 3 10 status = 0 0 3 You win status = 10 10 10 status = 0 5 10 status = 0 4 5 status = 0 3 4 status = 0 1 3 You win status = 10 10 10 status = 0 9 10 status = 0 5 9 status = 0 4 5 status = 0 1 4 You win status = 10 10 10 status = 0 1 10 You win status = 10 10 10 status = 0 9 10 status = 0 2 9 status = 0 1 2 You win status = 10 10 10 status = 0 0 10 You win status = 10 10 10 status = 0 3 10 status = 0 0 3 You win status = 10 10 10 status = 0 6 10 status = 0 2 6 status = 0 0 2 You win status = 10 10 10 status = 0 3 10 status = 0 1 3 You win status = 10 10 10 status = 0 1 10 You win status = 10 10 10 status = 0 4 10 status = 0 0 4 You win status = 10 10 10 status = 0 1 10 You win status = 10 10 10 status = 0 0 10 You win status = 10 10 10 status = 0 1 10 You win status = 10 10 10 status = 0 3 10 status = 0 0 3 You win status = 10 10 10 status = 0 0 10 You win status = 10 10 10 status = 0 2 10 status = 0 1 2 You win status = 10 10 10 status = 0 9 10 status = 0 7 9 status = 0 2 7 status = 0 0 2 You win status = 10 10 10 status = 0 1 10 You win status = 10 10 10 status = 0 9 10 status = 0 3 9 status = 0 1 3 You win status = 10 10 10 status = 0 2 10 status = 0 1 2 You win status = 10 10 10 sta...

Suggested Problems

More from this Author18