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 97907

Submitted on 12 Jun 2012 by Mark

Correct

127Size
Leading solution size is 57.
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
 
%%
hm = [0 1 0 0 0 0 0 0 1 1 0 1 1
      0 1 0 0 0 0 0 0 1 0 0 1 0
      0 0 0 1 0 0 0 0 1 0 0 0 0
      0 0 0 0 0 0 0 0 0 0 0 0 0];
y_correct.flag = false;
y_correct.usedCards = logical([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])
assert(isequal(isStraight(hm),y_correct))
y_correct =
         flag: 0
    usedCards: [4x13 logical]
hm =
  Columns 1 through 10
     0     1     0     0     0     0     0     0     1     1
     0     1     0     0     0     0     0     0     1     0
     0     0     0     1     0     0     0     0     1     0
     0     0     0     0     0     0     0     0     0     0
  Columns 11 through 14
     0     1     1     0
     0     1     0     0
     0     0     0     0
     0     0     0     0
w =
  Columns 1 through 10
     0     1     1     2     2     2     1     1     1     2
  Columns 11 through 14
     2     3     4     3
n =
   Empty matrix: 1-by-0
out =
    flag: 0
2
Pass
 
%%
hm = [0 1 1 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 1 0 1 0
      0 0 0 0 1 0 0 0 0 0 0 0 0];
y_correct.flag = true;
y_correct.usedCards = logical([0 1 1 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 0
                               0 0 0 0 1 0 0 0 0 0 0 0 0])
assert(isequal(isStraight(hm),y_correct))
y_correct =
         flag: 1
    usedCards: [4x13 logical]
hm =
  Columns 1 through 10
     0     1     1     0     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     1
     0     0     0     0     1     0     0     0     0     0
  Columns 11 through 14
     0     0     0     0
     0     0     0     0
     0     1     0     0
     0     0     0     0
w =
  Columns 1 through 10
     0     1     2     3     4     5     4     3     2     2
  Columns 11 through 14
     1     2     2     2
n =
     6
out =
    flag: 1
3
Pass
 
%%
hm = [0 1 1 0 0 0 0 0 0 0 0 0 0
      0 0 0 0 0 1 0 0 0 0 0 0 0
      0 1 0 1 0 0 0 0 0 1 0 1 0
      0 0 0 0 1 0 0 0 0 0 0 0 0];
y_correct.flag = true;
y_correct.usedCards = logical([0 1 1 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 0
                               0 0 0 0 1 0 0 0 0 0 0 0 0])
assert(isequal(isStraight(hm),y_correct))
y_correct =
         flag: 1
    usedCards: [4x13 logical]
hm =
  Columns 1 through 10
     0     1     1     0     0     0     0     0     0     0
     0     0     0     0     0     1     0     0     0     0
     0     1     0     1     0     0     0     0     0     1
     0     0     0     0     1     0     0     0     0     0
  Columns 11 through 14
     0     0     0     0
     0     0     0     0
     0     1     0     0
     0     0     0     0
w =
  Columns 1 through 10
     0     1     2     3     4     5     4     3     2     2
  Columns 11 through 14
     1     2     2     2
n =
     6
out =
    flag: 1
4
Pass
 
%%
hm = [0 1 1 0 0 0 0 0 0 0 0 0 0
      1 0 0 0 0 1 0 0 0 0 0 0 0
      0 1 0 1 0 0 0 0 0 1 0 1 0
      0 0 0 0 1 0 0 0 0 0 0 0 0];
y_correct.flag = true;
y_correct.usedCards = logical([0 1 1 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 0
                               0 0 0 0 1 0 0 0 0 0 0 0 0])
assert(isequal(isStraight(hm),y_correct))
y_correct =
         flag: 1
    usedCards: [4x13 logical]
hm =
  Columns 1 through 10
     0     1     1     0     0     0     0     0     0     0
     1     0     0     0     0     1     0     0     0     0
     0     1     0     1     0     0     0     0     0     1
     0     0     0     0     1     0     0     0     0     0
  Columns 11 through 14
     0     0     0     0
     0     0     0     1
     0     1     0     0
     0     0     0     0
w =
  Columns 1 through 10
     1     2     3     4     5     5     4     3     2     2
  Columns 11 through 14
     1     2     2     3
n =
     6
out =
    flag: 1
5
Pass
 
%%
hm = [0 1 1 0 0 0 0 0 0 0 1 0 0
      0 0 0 0 0 1 0 0 0 0 0 0 1
      0 1 0 1 0 0 0 0 0 1 0 1 0
      1 0 0 0 1 0 0 0 0 0 0 0 1];
y_correct.flag = true;
y_correct.usedCards = logical([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 1
                               0 0 0 0 0 0 0 0 0 1 0 1 0
                               1 0 0 0 0 0 0 0 0 0 0 0 0])
assert(isequal(isStraight(hm),y_correct))
y_correct =
         flag: 1
    usedCards: [4x13 logical]
hm =
  Columns 1 through 10
     0     1     1     0     0     0     0     0     0     0
     0     0     0     0     0     1     0     0     0     0
     0     1     0     1     0     0     0     0     0     1
     1     0     0     0     1     0     0     0     0     0
  Columns 11 through 14
     1     0     0     0
     0     0     1     0
     0     1     0     0
     0     0     1     1
w =
  Columns 1 through 10
     1     2     3     4     5     5     4     3     2     2
  Columns 11 through 14
     2     3     4     5
n =
    14
out =
    flag: 1
out =
         flag: 1
    usedCards: [4x14 double]