Cody

Solution 1539619

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))

You win Error: You must remove at least one line You win You win You win You win Error: You must remove at least one line You win You win You win You win You win Error: You must remove at least one line You win You win You win Error: You must remove at least one line Error: You must remove at least one line You win You win You win You win You win You win You win Error: You must remove at least one line Error: You must remove at least one line Error: You must remove at least one line You win You win Error: You must remove at least one line You win You win You win You win Error: You must remove at least one line You win You win You win You win You win Error: You must remove at least one line You win You win You win You win You win You win You win Error: You must remove at least one line You win You win You win Error: You must remove at least one line Error: You must remove at least one line You win You win You win You win You win You win You win You win You win You win You win You win You win You win You win You win You win You win You win You win You win You win You win Error: You must remove at least one line You win You win You win You win Error: You must remove at least one line You win Error: You must remove at least one line You win You win You win You win You win You win You win You win You win You win You win You win You win You win number_of_wins = 83

Assertion failed.

Suggested Problems

More from this Author18