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 205597

Submitted on 18 Feb 2013 by Robert G

Correct

85Size
Leading solution size is 12.
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
 
%%
tiles = [7 12 8 6 9];
nRows = 2;
nCols = 2;
omit = 6;
board = fill_board(tiles,nRows,nCols);
tiles_used = tiles(board(:));
assert(isequal(setdiff(tiles,tiles_used),omit))
L =
     4
Lt =
     5
value =
     6
inde =
     4
tiles =
     7    12     8   NaN     9
ind =
     1     2     3   NaN     5
ind2 =
     0     0     0     1     0
tiles =
     7    12     8     9
ind =
     1     2     3     5
board =
     1     3
     2     5
2
Pass
 
%%
tiles = [12  6  1 20 18  7  4 17];
nRows = 3;
nCols = 2;
omit = [1 4];
board = fill_board(tiles,nRows,nCols);
tiles_used = tiles(board(:));
assert(isequal(setdiff(tiles,tiles_used),omit))
L =
     6
Lt =
     8
value =
     1
inde =
     3
tiles =
    12     6   NaN    20    18     7     4    17
ind =
     1     2   NaN     4     5     6     7     8
value =
     4
inde =
     7
tiles =
    12     6   NaN    20    18     7   NaN    17
ind =
     1     2   NaN     4     5     6   NaN     8
ind2 =
     0     0     1     0     0     0     1     0
tiles =
    12     6    20    18     7    17
ind =
     1     2     4     5     6     8
board =
     1     5
     2     6
     4     8
3
Pass
 
%%
tiles = [2 10 25 38 39 5 24 14 4];
nRows = 2;
nCols = 3;
omit = [2 4 5];
board = fill_board(tiles,nRows,nCols);
tiles_used = tiles(board(:));
assert(isequal(setdiff(tiles,tiles_used),omit))
L =
     6
Lt =
     9
value =
     2
inde =
     1
tiles =
   NaN    10    25    38    39     5    24    14     4
ind =
   NaN     2     3     4     5     6     7     8     9
value =
     4
inde =
     9
tiles =
   NaN    10    25    38    39     5    24    14   NaN
ind =
   NaN     2     3     4     5     6     7     8   NaN
value =
     5
inde =
     6
tiles =
   NaN    10    25    38    39   NaN    24    14   NaN
ind =
   NaN     2     3     4     5   NaN     7     8   NaN
ind2 =
     1     0     0     0     0     1     0     0     1
tiles =
    10    25    38    39    24    14
ind =
     2     3     4     5     7     8
board =
     2     4     7
     3     5     8