Cody

Solution 1539623

Submitted on 24 May 2018
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

This solution is outdated. To rescore this solution, sign in.

Test Suite

Test Status Code Input and Output
1   Fail
for i=1:100 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),100))

status = 10 10 10 status = 0 4 10 status = 0 3 1 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 8 10 status = 0 3 1 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 4 10 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 9 10 status = 0 4 1 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 3 10 status = 0 2 1 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 3 10 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 9 10 status = 0 4 1 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 5 10 status = 0 1 1 Error: You must remove at least one line status = 10 10 10 status = 0 5 10 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 5 10 status = 0 1 1 Error: You must remove at least one line status = 10 10 10 status = 0 4 10 status = 0 1 1 Error: You must remove at least one line status = 10 10 10 status = 0 1 10 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 7 10 status = 0 4 1 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 3 10 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 7 10 status = 0 5 1 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 6 10 status = 0 5 1 status = 0 0 1 Error: You must remove at least one line 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 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 1 10 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 7 10 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 8 10 status = 0 1 1 Error: You must remove at least one line status = 10 10 10 status = 0 7 10 status = 0 2 1 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 3 10 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 8 10 status = 0 1 1 Error: You must remove at least one line status = 10 10 10 status = 0 5 10 status = 0 3 1 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 1 10 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 1 10 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 9 10 status = 0 8 1 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 1 10 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 7 10 status = 0 4 1 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 5 10 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 1 10 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 5 10 status = 0 2 1 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 1 10 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 8 10 status = 0 1 1 Error: You must remove at least one line status = 10 10 10 status = 0 7 10 status = 0 5 1 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 8 10 status = 0 6 1 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 0 10 You win status = 10 10 10 status = 0 8 10 status = 0 3 1 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 7 10 status = 0 1 1 Error: You must remove at least one line status = 10 10 10 status = 0 0 10 You win status = 10 10 10 status = 0 2 10 status = 0 1 1 Error: You must remove at least one line status = 10 10 10 status = 0 3 10 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 0 10 You win status = 10 10 10 status = 0 3 10 status = 0 1 1 Error: You must remove at least one line status = 10 10 10 status = 0 2 10 status = 0 1 1 Error: You must remove at least one line status = 10 10 10 status = 0 7 10 status = 0 4 1 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 7 10 status = 0 3 1 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 4 10 status = 0 1 1 Error: You must remove at least one line status = 10 10 10 status = 0 7 10 status = 0 6 1 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 5 10 status = 0 1 1 Error: You must remove at least one line status = 10 10 10 status = 0 8 10 status = 0 7 1 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 9 10 status = 0 6 1 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 0 10 You win status = 10 10 10 status = 0 8 10 status = 0 5 1 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 2 10 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 6 10 status = 0 1 1 Error: You must remove at least one line status = 10 10 10 status = 0 2 10 status = 0 1 1 Error: You must remove at least one line status = 10 10 10 status = 0 3 10 status = 0 2 1 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 0 10 You win status = 10 10 10 status = 0 3 10 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 1 10 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 0 10 You win status = 10 10 10 status = 0 3 10 status = 0 2 1 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 7 10 status = 0 4 1 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 5 10 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 1 10 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 0 10 You win status = 10 10 10 status = 0 1 10 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 4 10 status = 0 2 1 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 8 10 status = 0 7 1 status = 0 0 1 Error: You must remove at least one line status = 10 10 10 status = 0 7 10 status = 0 2 1 ...

Assertion failed.

Suggested Problems

More from this Author18