Cody

# Problem 1700. Solve the picross! (Easy)

Solution 1741430

Submitted on 3 Mar 2019 by William
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
% 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
% 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
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
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
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
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 ) )