Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 341950

Submitted on 29 Oct 2013 by Tim

Correct

434Size
Leading solution size is 297.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%% MEET MATT....
% By Tom O'Connell (sensei69)
% http://webpbn.com/index.cgi?id=12795
horz = { ...
    [], [1, 1], 5, 7, [1, 3, 1, 1], ...
    [2, 7], [1, 2, 2, 1], [1, 3, 2, 2], [1, 5, 4], [12, 1], ...
    [12, 1], 14, 14, [2, 6], [3, 3] };
vert = { ...
    5, [2, 4], 7, 8, [6, 1], ...
    6, 6, [4, 5], [6, 5], [5, 7], ...
    [2, 2, 7], [5, 7], [3, 1, 2, 3, 1], [5, 2], 4 };
getseq = @(soluce) arrayfun( @(i)cellfun( 'length', regexp( char(soluce(i,:)+'0'), '1+', 'match' ) ), 1:size(soluce,1), 'Uniformoutput', false );
equalseq = @(actual,expected) length(actual) == length(expected) && all( cellfun( @(a,e)length(a) == length(e) && all( a == e ), actual, expected ) );
checksoluce = @( soluce, horz, vert ) size(soluce,1) == length(horz) && size(soluce,2) == length(vert) && equalseq( getseq( soluce ), horz ) && equalseq( getseq( soluce' ), vert );
assert( checksoluce( solvePicross( horz, vert ), horz, vert ) )

                    
2
Pass
 
%% PEACE
% By shay yatim (shay3979)
% http://webpbn.com/index.cgi?id=4496
horz = { ...
    6, [2, 2, 2], [2, 2, 2], [1, 2, 1], [1, 4, 1], ...
    [1, 6, 1], [3, 2, 3], [1, 2, 2], [2, 2, 2], 6 };
vert = { ...
    6, [2, 1, 1], [2, 2, 2], [1, 2, 1], 10, ...
    10, [1, 2, 1], [2, 2, 2], [2, 3], 6 };
getseq = @(soluce) arrayfun( @(i)cellfun( 'length', regexp( char(soluce(i,:)+'0'), '1+', 'match' ) ), 1:size(soluce,1), 'Uniformoutput', false );
equalseq = @(actual,expected) length(actual) == length(expected) && all( cellfun( @(a,e)length(a) == length(e) && all( a == e ), actual, expected ) );
checksoluce = @( soluce, horz, vert ) size(soluce,1) == length(horz) && size(soluce,2) == length(vert) && equalseq( getseq( soluce ), horz ) && equalseq( getseq( soluce' ), vert );
assert( checksoluce( solvePicross( horz, vert ), horz, vert ) )

                    
3
Pass
 
%% MATLAB LOGO
horz = { ...
    1, 3, [1, 2], 5, [1, 4], ...
    [2, 4], [3, 4], [4, 6], [1, 6], [3, 6], ...
    [7, 8], [8, 8], [5, 9], [4, 10], [6, 2], ...
    [6, 2], 6, 4, 3, 2 };
vert = { 1, 2, 3, 4, 5, ...
    5, 7, [2, 2, 2], [2, 6], [3, 8], ...
    [2, 9], [2, 11], [1, 14], 15, 13, ...
    11, 7, 5, 3, 1 };
getseq = @(soluce) arrayfun( @(i)cellfun( 'length', regexp( char(soluce(i,:)+'0'), '1+', 'match' ) ), 1:size(soluce,1), 'Uniformoutput', false );
equalseq = @(actual,expected) length(actual) == length(expected) && all( cellfun( @(a,e)length(a) == length(e) && all( a == e ), actual, expected ) );
checksoluce = @( soluce, horz, vert ) size(soluce,1) == length(horz) && size(soluce,2) == length(vert) && equalseq( getseq( soluce ), horz ) && equalseq( getseq( soluce' ), vert );
assert( checksoluce( solvePicross( horz, vert ), horz, vert ) )

                    
4
Pass
 
%% THE INVASION HAS BEGUN
horz = { ...
    [], [1, 1], [1, 1], 7, [2, 3, 2], ...
    11, [1, 7, 1], [1 1 1 1], [2 2], [] };
vert = { ...
    [], [], 3, 2, [1 5], ...
    [2, 2, 1], [4, 1], 4, [4, 1], [2, 2, 1], ...
    [1, 5], 2, 3, [], [] };
getseq = @(soluce) arrayfun( @(i)cellfun( 'length', regexp( char(soluce(i,:)+'0'), '1+', 'match' ) ), 1:size(soluce,1), 'Uniformoutput', false );
equalseq = @(actual,expected) length(actual) == length(expected) && all( cellfun( @(a,e)length(a) == length(e) && all( a == e ), actual, expected ) );
checksoluce = @( soluce, horz, vert ) size(soluce,1) == length(horz) && size(soluce,2) == length(vert) && equalseq( getseq( soluce ), horz ) && equalseq( getseq( soluce' ), vert );
assert( checksoluce( solvePicross( horz, vert ), horz, vert ) )

                    
5
Pass
 
%% YUMMY
horz = { ...
    [], 8, 14, 16, 20, ...
    22, 24, 25, 22, 21, ...
    19, 17, 16, 14, 15, ...
    16, 18, 20, 22, 22, ...
    24, 25, 26, 24, 22, ...
    20, 18, 14, 8, [] };
vert = { ...
    [], 7, 12, 16, 18, ...
    20, 22, 23, 24, 26, ...
    26, 26, 28, 28, 28, ...
    [12, 15], [12, 14], [11, 13], [11, 13], [10, 12], ...
    [9, 11], [8, 10], [8, 10], [6, 8], [5, 7], ...
    [4, 6], [3, 4], [2, 3], 1, [] };
getseq = @(soluce) arrayfun( @(i)cellfun( 'length', regexp( char(soluce(i,:)+'0'), '1+', 'match' ) ), 1:size(soluce,1), 'Uniformoutput', false );
equalseq = @(actual,expected) length(actual) == length(expected) && all( cellfun( @(a,e)length(a) == length(e) && all( a == e ), actual, expected ) );
checksoluce = @( soluce, horz, vert ) size(soluce,1) == length(horz) && size(soluce,2) == length(vert) && equalseq( getseq( soluce ), horz ) && equalseq( getseq( soluce' ), vert );
assert( checksoluce( solvePicross( horz, vert ), horz, vert ) )

                    
6
Pass
 
%% GOTTA CATCH 'EM ALL
horz = { ...
    [4, 14, 4], [3, 10], [2, 6, 2, 3], [1, 1, 5, 6, 3, 1], [4, 3, 6, 2, 2], ...
    [1, 3, 6, 2, 3], [2, 1, 2, 2, 2, 5, 1, 1], [2, 1, 2, 2, 3, 8, 2, 1], [2, 7, 5, 5, 2], [3, 4, 4, 1, 6, 1], ...
    [4, 4, 1, 2, 2], [2, 2, 4, 6, 3], [1, 2, 2, 2, 1, 2, 2, 4, 1, 3], [2, 2, 2, 3, 1, 2, 4], [3, 4, 11, 5] };
vert = { ...
    [4, 10], [3, 1, 6, 2], [2, 1, 2, 1, 1], [1, 2, 3, 1, 2], [1, 2, 1], ...
    [4, 1], [4, 1, 1], [2, 1], [2, 2, 1], [2, 2, 1], ...
    [1, 1], [2, 1, 2], [4, 5, 1], 15, 15, ...
    [6, 4, 2], [4, 2, 1, 1], [3, 7, 1, 1], [2, 3, 2, 1, 2], [2, 7, 2, 1], ...
    [2, 10, 1], [1, 11, 1], [1, 6, 1, 2, 1], [1, 1, 2, 1, 1, 1], [1, 1, 1], ...
    [4, 1, 1], [1, 3, 1, 2], [1, 2, 1, 1, 4], [1, 1, 2, 1, 5], [1, 12] };
getseq = @(soluce) arrayfun( @(i)cellfun( 'length', regexp( char(soluce(i,:)+'0'), '1+', 'match' ) ), 1:size(soluce,1), 'Uniformoutput', false );
equalseq = @(actual,expected) length(actual) == length(expected) && all( cellfun( @(a,e)length(a) == length(e) && all( a == e ), actual, expected ) );
checksoluce = @( soluce, horz, vert ) size(soluce,1) == length(horz) && size(soluce,2) == length(vert) && equalseq( getseq( soluce ), horz ) && equalseq( getseq( soluce' ), vert );
assert( checksoluce( solvePicross( horz, vert ), horz, vert ) )