No BSD License  

Highlights from
MATLAB Golf Contest Test Suite

from MATLAB Golf Contest Test Suite by Mike Thomas
Generates the test suites for the MATLAB Golf Contest.

createsnake
function holes = createsnake

holes = [];

a = ceil(hilb(10)*100);
a(2:6,1:5) = spiral(5)+17;
b = [24; 34; 35; 25; 15; 14; 13; 23; 33; 43; 44; 45; 46; 36; 26; 16; 6; 5;
    4; 3; 2; 12; 22; 32; 42];

holes(end+1).a = a;
holes(end).b = b;

a=magic(2);
b=[4;3];

holes(end+1).a = a;
holes(end).b = b;

a=reshape(1:(7*4),7,4);
a(1,:)=8;
a(21)=15;
b=[8:14 21]';

holes(end+1).a = a;
holes(end).b = b;

a=reshape(1:(3*5),3,5);
a(:,1:2:end)=flipud(a(:,1:2:end));
b = [3;2;1;4;5;6;9;8;7;10;11;12;15;14;13];

holes(end+1).a = a;
holes(end).b = b;

a = fliplr(diag(1:2:16)+diag(2:2:15,1)+1);
b = [
    58
    57
    49
    50
    42
    43
    35
    36
    28
    29
    21
    22
    14
    15
    7
    8
    ];

holes(end+1).a = a;
holes(end).b = b;

a = reshape(gallery('circul',1:12),16,9);
b = (144:-1:133)';

holes(end+1).a = a;
holes(end).b = b;

a = reshape(cumsum(gallery('gearmat',12,2,10)),9,16)+2;
b = [25;26;35;36];

holes(end+1).a = a;
holes(end).b = b;

a = full(gallery('tridiag',32:41,1:2:22,2:2:21))+20;
a(:,7:end)=flipud(a(:,7:end));
a(a==0)=15;
a = flipud(a);
b = [
    11
    22
    21
    32
    31
    42
    41
    52
    51
    62
    61
    72
    73
    84
    85
    96
    97
    108
    109
    120
    121
    ];

holes(end+1).a = a;
holes(end).b = b;

a = zeros(10,14);
b = [128:-10:88 87:-1:83 73 74 64 65 55 56]';
for ii=1:length(b)
    a(b(ii))=ii+4;
end
ind = find(a==0);
a(ind)=mod(1:length(ind),max(a(b)))+3;

holes(end+1).a = a;
holes(end).b = b;

a = pascal(5); a(a==1)=6; a(15)=6; a(16)=7;
b = [7 12 17 22 21 16]';

holes(end+1).a = a;
holes(end).b = b;

a = [3 1 2;5 4 3];
b = [3 5 6 4 2]';

holes(end+1).a = a;
holes(end).b = b;

Contact us at files@mathworks.com