Cody

Problem 556. Stuff the Board

Solution 1720543

Submitted on 4 Feb 2019 by Nikolaos Nikolaou
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status 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))

board = 0 0 0 0 t = 4 t1 = 12 9 8 7 6 t2 = 12 9 8 7 t3 = 2 t3 = 2 5 t3 = 2 5 3 t3 = 2 5 3 1 board = 2 3 5 1

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))

board = 0 0 0 0 0 0 t = 6 t1 = 20 18 17 12 7 6 4 1 t2 = 20 18 17 12 7 6 t3 = 4 t3 = 4 5 t3 = 4 5 8 t3 = 4 5 8 1 t3 = 4 5 8 1 6 t3 = 4 5 8 1 6 2 board = 4 1 5 6 8 2

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))

board = 0 0 0 0 0 0 t = 6 t1 = 39 38 25 24 14 10 5 4 2 t2 = 39 38 25 24 14 10 t3 = 5 t3 = 5 4 t3 = 5 4 3 t3 = 5 4 3 7 t3 = 5 4 3 7 8 t3 = 5 4 3 7 8 2 board = 5 3 8 4 7 2