from
MATLAB Golf Contest Test Suite
by Mike Thomas
Generates the test suites for the MATLAB Golf Contest.
|
| createheaviest
|
function holes = createheaviest
holes = [];
% original example
a = [ 1 2 3 3 3;
2 2 3 3 3;
8 8 3 3 3;
8 8 1 1 2];
b = 32;
holes(end+1).a = a;
holes(end).b = b;
% a 2x2 matrix
a = 1000*ones(2);
b = 4000;
holes(end+1).a = a;
holes(end).b = b;
% two sub-matrixes with the same number (a)
a = [ 7 7 7 4 4 4;
7 7 7 4 4 4;
2 4 4 4 4 4;
1 4 4 5 5 2;
1 3 3 5 5 100];
b = 4*9;
holes(end+1).a = a;
holes(end).b = b;
% two sub-matrixes with the same number (b)
a = [ 7 7 7 4 4 4;
7 7 7 4 4 4;
4 4 4 4 4 4;
4 4 4 5 5 2;
4 4 4 5 5 100];
b = 4*9;
holes(end+1).a = a;
holes(end).b = b;
%four sub-matrixes
a = [ 7 7 7 4 7 7;
7 7 7 4 7 7;
40 40 40 40 40 40;
7 7 7 4 7 7;
7 7 7 4 7 7];
b = 4 * 7;
holes(end+1).a = a;
holes(end).b = b;
% overlapped matrixes
a = [ 1 2 3 4 4 4;
2 5 5 5 5 4;
2 5 5 5 5 4;
1 4 4 5 5 2;
1 3 3 5 5 100];
b = 5 * 4;
holes(end+1).a = a;
holes(end).b = b;
% solution in the borders (a)
a = [ 100 2 5 5 5 5 5 5 6 6 7 7 8 8 9 9 9;
100 2 5 5 5 5 5 5 6 6 7 7 8 8 9 9 9];
b = 4 * 9;
holes(end+1).a = a;
holes(end).b = b;
% solution in the borders (b)
a = [ 1 1 1 2 5 5 5 5 5 5 6 6 7 7 8 8 9 9 9;
1 1 1 2 5 5 5 5 5 5 6 6 7 7 8 8 9 9 9];
a = 10-a';
b = 4 * 9;
holes(end+1).a = a;
holes(end).b = b;
% the whole matrix
a = ones(10);
b = 100;
holes(end+1).a = a;
holes(end).b = b;
% almost the whole matrix
a = ones(10); a(1)=0;
b = 81;
holes(end+1).a = a;
holes(end).b = b;
% another one
a=gallery('moler',10)+flipud(gallery('moler',10));
b=7*9;
holes(end+1).a = a;
holes(end).b = b;
|
|
Contact us at files@mathworks.com