Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 245985

Submitted on 18 May 2013 by Yaroslav

Correct

588Size
Leading solution size is 580.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
clear
clc

                    
2
Pass
 
%%
hm1 = [0 1 0 0 0 0 0 0 0 0 0 0 1
       0 1 0 0 0 0 0 0 0 0 0 0 0
       0 0 0 1 0 0 0 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 0 0 0 0 0];
om1 = [0 0 0 0 0 0 0 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 0 0 0 0 0];
hm2 = [0 1 0 0 0 0 0 0 0 0 0 0 1
       0 1 0 0 0 0 0 0 0 0 0 0 0
       0 0 0 1 0 0 0 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 0 0 0 0 0];
om2 = [0 0 0 0 0 0 0 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 0 0 0 0 0];
out.hm{1} = om1;
out.hm{2} = om2;
out.winner = 0;
assert(isequal(selectBestHand(hm1,hm2),out))

                    
3
Pass
 
%%
hm1 = [0 1 0 0 0 0 0 0 0 0 0 0 1
       0 1 0 0 0 0 0 0 0 0 0 0 1
       0 0 0 1 0 0 0 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 0 0 0 0 0];
om1 = [0 1 0 0 0 0 0 0 0 0 0 0 1
       0 1 0 0 0 0 0 0 0 0 0 0 1
       0 0 0 1 0 0 0 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 0 0 0 0 0];
hm2 = [0 1 0 0 0 0 0 0 0 0 0 0 1
       0 1 0 0 0 0 0 0 0 0 0 0 0
       0 1 0 1 0 0 0 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 0 0 0 0 0];
om2 = [0 1 0 0 0 0 0 0 0 0 0 0 1
       0 1 0 0 0 0 0 0 0 0 0 0 0
       0 1 0 1 0 0 0 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 0 0 0 0 0];
out.hm{1} = om1;
out.hm{2} = om2;
out.winner = 2;
assert(isequal(selectBestHand(hm1,hm2),out))

                    
4
Pass
 
%%
hm1 = [0 1 0 0 0 0 0 0 0 0 0 0 1
       0 1 0 0 0 0 0 0 0 0 0 0 1
       0 1 0 1 0 0 0 0 0 0 0 0 0
       0 1 0 0 0 0 0 0 0 0 0 0 0];
om1 = [0 1 0 0 0 0 0 0 0 0 0 0 1
       0 1 0 0 0 0 0 0 0 0 0 0 0
       0 1 0 0 0 0 0 0 0 0 0 0 0
       0 1 0 0 0 0 0 0 0 0 0 0 0];
hm2 = [0 1 0 0 0 0 0 0 0 0 0 0 1
       0 1 0 0 0 0 0 0 0 0 0 0 1
       0 1 0 0 0 0 1 0 0 0 0 0 0
       0 0 0 1 0 0 0 0 0 0 0 0 0];
om2 = [0 1 0 0 0 0 0 0 0 0 0 0 1
       0 1 0 0 0 0 0 0 0 0 0 0 1
       0 1 0 0 0 0 0 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 0 0 0 0 0];
out.hm{1} = om1;
out.hm{2} = om2;
out.winner = 1;
assert(isequal(selectBestHand(hm1,hm2),out))

                    
5
Pass
 
%%
hm1 = [0 1 0 0 0 0 0 0 0 0 0 0 1
       0 1 0 0 0 0 0 0 0 0 0 0 1
       0 1 0 1 0 0 0 0 0 0 0 0 0
       0 1 0 0 0 0 0 0 0 0 0 0 0];
om1 = [0 1 0 0 0 0 0 0 0 0 0 0 1
       0 1 0 0 0 0 0 0 0 0 0 0 0
       0 1 0 0 0 0 0 0 0 0 0 0 0
       0 1 0 0 0 0 0 0 0 0 0 0 0];
hm2 = [0 1 0 0 0 0 0 0 0 0 0 1 0
       0 1 0 0 0 0 0 0 0 0 0 0 0
       0 1 0 0 0 0 0 0 0 0 0 0 0
       0 1 0 0 0 0 0 0 0 0 0 0 0];
om2 = [0 1 0 0 0 0 0 0 0 0 0 1 0
       0 1 0 0 0 0 0 0 0 0 0 0 0
       0 1 0 0 0 0 0 0 0 0 0 0 0
       0 1 0 0 0 0 0 0 0 0 0 0 0];
out.hm{1} = om1;
out.hm{2} = om2;
out.winner = 1;
assert(isequal(selectBestHand(hm1,hm2),out))

                    
6
Pass
 
%%
hm1 = [0 1 0 0 0 0 0 0 0 0 0 0 1
       0 1 0 0 0 0 0 0 0 0 0 0 1
       0 0 0 1 0 0 1 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 1 0 0 0 0];
om1 = [0 1 0 0 0 0 0 0 0 0 0 0 1
       0 1 0 0 0 0 0 0 0 0 0 0 1
       0 0 0 0 0 0 0 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 1 0 0 0 0];
hm2 = [0 1 0 0 0 0 0 0 0 0 0 1 1
       0 1 0 0 0 0 0 0 0 0 0 1 0
       0 0 0 0 0 0 1 0 0 0 0 0 0
       0 0 0 0 1 0 0 0 0 0 0 0 0];
om2 = [0 1 0 0 0 0 0 0 0 0 0 1 1
       0 1 0 0 0 0 0 0 0 0 0 1 0
       0 0 0 0 0 0 0 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 0 0 0 0 0];
out.hm{1} = om1;
out.hm{2} = om2;
out.winner = 1;
assert(isequal(selectBestHand(hm1,hm2),out))

                    
7
Pass
 
%%
hm1 = [1 1 1 1 1 0 0 0 0 0 0 0 1
       0 1 0 0 1 0 0 0 0 0 0 0 1
       0 0 0 1 0 0 1 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 1 0 0 0 0];
om1 = [1 1 1 1 1 0 0 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 0 0 0 0 0];
hm2 = [0 1 0 0 0 0 0 0 0 0 0 1 1
       0 1 0 0 0 0 0 0 0 0 0 1 0
       0 0 0 0 0 0 1 0 0 0 0 0 0
       0 0 0 0 1 0 0 0 0 0 0 0 0];
om2 = [0 1 0 0 0 0 0 0 0 0 0 1 1
       0 1 0 0 0 0 0 0 0 0 0 1 0
       0 0 0 0 0 0 0 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 0 0 0 0 0];
out.hm{1} = om1;
out.hm{2} = om2;
out.winner = 1;
assert(isequal(selectBestHand(hm1,hm2),out))

                    
8
Pass
 
%%
hm1 = [1 1 1 1 1 0 0 0 0 0 0 0 1
       0 1 0 0 1 0 0 0 0 0 0 0 1
       0 0 0 1 0 0 1 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 1 0 0 0 0];
om1 = [1 1 1 1 1 0 0 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 0 0 0 0 0];
hm2 = [1 1 1 1 1 1 0 0 0 0 0 1 1
       0 0 0 0 0 0 0 0 0 0 0 1 0
       0 0 0 0 0 0 1 0 0 0 0 0 0
       0 0 0 0 1 0 0 0 0 0 0 0 0];
om2 = [0 1 1 1 1 1 0 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 0 0 0 0 0];
out.hm{1} = om1;
out.hm{2} = om2;
out.winner = 2;
assert(isequal(selectBestHand(hm1,hm2),out))

                    
9
Pass
 
%%
hm1 = [0 1 0 0 1 0 0 0 0 0 0 0 0
       0 1 0 0 0 0 0 0 0 0 0 0 1
       0 0 0 1 0 0 1 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 0 0 0 0 0];
om1 = [0 1 0 0 1 0 0 0 0 0 0 0 0
       0 1 0 0 0 0 0 0 0 0 0 0 1
       0 0 0 0 0 0 1 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 0 0 0 0 0];
hm2 = [0 0 0 0 1 1 0 0 0 0 0 1 1
       0 0 0 0 0 0 0 0 0 0 0 0 0
       0 0 0 0 0 0 1 0 0 0 0 0 0
       0 0 0 0 1 0 0 0 0 0 0 0 0];
om2 = [0 0 0 0 1 0 0 0 0 0 0 1 1
       0 0 0 0 0 0 0 0 0 0 0 0 0
       0 0 0 0 0 0 1 0 0 0 0 0 0
       0 0 0 0 1 0 0 0 0 0 0 0 0];
out.hm{1} = om1;
out.hm{2} = om2;
out.winner = 2;
assert(isequal(selectBestHand(hm1,hm2),out))

                    
10
Pass
 
%%
hm1 = [0 1 0 0 0 0 0 0 0 0 0 0 1
       0 1 0 0 0 0 0 0 0 0 0 0 1
       0 0 0 1 0 0 1 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 1 0 0 0 0];
om1 = [0 1 0 0 0 0 0 0 0 0 0 0 1
       0 1 0 0 0 0 0 0 0 0 0 0 1
       0 0 0 0 0 0 0 0 0 0 0 0 0
       0 0 0 0 0 0 0 0 1 0 0 0 0];
hm2 = [0 1 0 0 0 0 0 0 0 0 0 0 1
       0 1 0 0 0 0 0 0 0 0 0 0 1
       0 0 0 0 0 0 1 0 0 0 0 1 0
       0 0 0 0 1 0 0 0 0 0 0 0 0];
om2 = [0 1 0 0 0 0 0 0 0 0 0 0 1
       0 1 0 0 0 0 0 0 0 0 0 0 1
       0 0 0 0 0 0 0 0 0 0 0 1 0
       0 0 0 0 0 0 0 0 0 0 0 0 0];
out.hm{1} = om1;
out.hm{2} = om2;
out.winner = 2;
assert(isequal(selectBestHand(hm1,hm2),out))