Problem 556. Stuff the Board

You have a stack of tiles to put onto an array-like playing board. Each tile has a number (always an integer), and the board varies in size (you are given dimensions nRows and nCols). You need to put the high-value tiles on the table in any order.

What you return is an array the same size as the board in which each element is a index to an element of the original vector of tiles.


 Input tiles = [7 12 8 6 9]
       nRows = 2
       nCols = 2
 Output is [ 1 2
             3 5 ]

The numbers in the output matrix can appear in any order. What matters is that the indices [1 2 3 5] do appear and that the index 4 does not appear (since tiles(4) is the lowest number).

 Input tiles = [12  6  1 20 18  7  4 17]
       nRows = 3
       nCols = 2
 Output is [ 2 6
             4 8
             1 5 ]

This problem is associated with the MATLAB Tiles Contest running from April 4th to April 11th.

Solution Stats

46.35% Correct | 53.65% Incorrect
Last solution submitted on Sep 23, 2016

Problem Comments

Solution Comments


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

MATLAB Academy

New to MATLAB?

Learn MATLAB today!

Join the 15-year community celebration.

Play games and win prizes!

Learn more