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.
Examples:
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 ]
Solution Stats
Problem Comments
-
4 Comments
The problem description says the output array elements can be in any order but the test cases seem to prefer some unknown order. Solution 682952 produces an array with same elements as the actual solution but the tests fail. Need a better description of the output desired or a more robust test suite.
Solution 682952 produces correct array, but doesn't pass it to the output.
awesome question
Good Problem :)
Solution Comments
Show commentsProblem Recent Solvers541
Suggested Problems
-
25347 Solvers
-
2409 Solvers
-
Number of 1s in a binary string
9083 Solvers
-
Getting the absolute index from a matrix
246 Solvers
-
Find the sides of an isosceles triangle when given its area and height from its base to apex
1911 Solvers
More from this Author50
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!