Code covered by the BSD License  

Highlights from
MATLAB Contest - Blockbuster

image thumbnail
from MATLAB Contest - Blockbuster by The MATLAB Contest Team
All the files needed to develop and score an entry for the MATLABĀ® Programming Contest.

sprintf('results: %.0f\ntime: %.2f',results,timeElapsed); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function viewsolution(A,B) colormap([0 0 0;jet(max(A(:)))]) subplot(1,2,1); image(A+1); title(sprintf('Initial block loc
function [message,results,timeElapsed] = runcontest(drawboard)
% RUNCONTEST Test a Blockbuster contest entry.
%   [MESSAGE,RESULTS,TIME] = RUNCONTEST runs the M-file solver.m against all
%   the problems defined in testsuite_sample.mat. MESSAGE returns a summary
%   of the testing.  RESULTS measures how well the entry solved the problem
%   and TIME measures the time the entry took to compute its answer.
%
%   ... = RUNCONTEST(TRUE) shows each of the solutions.

% Copyright 2006 The MathWorks, Inc.

% Set run mode.
if (nargin == 0)
    drawboard = 0;
end

% Load the testsuite
load testsuite_sample testsuite

% Run the submission for each problem in the suite.
n = numel(testsuite);
solution = cell(n,1);
score = zeros(n,1);

time0 = cputime;
for i = 1:n
    solution{i} = solver(testsuite(i).board, testsuite(i).nmoves);
    if drawboard
        [score(i),A] = grade(testsuite(i).board, testsuite(i).nmoves, solution{i});
        viewsolution(testsuite(i).board,A)
        disp(score(i))
    end
end
timeElapsed = cputime-time0;

% Grade all answers.
if ~drawboard
    for i = 1:n
        score(i) = grade(testsuite(i).board, testsuite(i).nmoves, solution{i});
    end
end

% Report results.
results = sum(score);
message = sprintf('results: %.0f\ntime: %.2f',results,timeElapsed);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function viewsolution(A,B)
colormap([0 0 0;jet(max(A(:)))])
subplot(1,2,1); image(A+1);
title(sprintf('Initial block locations ~ %d',sum(A(:))))
axis equal; axis off;
subplot(1,2,2); image(B+1);
title(sprintf('Final block locations ~ %d',sum(B(:))))
axis equal; axis off;
pause

Contact us at files@mathworks.com