Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
str = '(()(()(()(()))))';
out = {'( )';
' ()( ) ';
' ()( ) ';
' ()( ) ';
' () '}
assert(isequal(braces(str),out))
out =
5×1 cell array
{'( )'}
{' ()( ) '}
{' ()( ) '}
{' ()( ) '}
{' () '}
str =
'(()(()(()(()))))'
str =
'))))'
part =
40 32 32 32 32 32 32 32 32 32 32 32
32 40 41 40 32 32 32 32 32 32 32 32
32 32 32 32 40 41 40 32 32 32 32 32
32 32 32 32 32 32 32 40 41 40 32 32
32 32 32 32 32 32 32 32 32 32 40 41
part1 =
32 32 32 41
32 32 41 32
32 41 32 32
41 32 32 32
32 32 32 32
sout =
5×16 char array
'( )'
' ()( ) '
' ()( ) '
' ()( ) '
' () '
out =
5×1 cell array
{'( )'}
{' ()( ) '}
{' ()( ) '}
{' ()( ) '}
{' () '}
|
2 | Pass |
str = '()'; % trivial test
out = {'()'};
assert(isequal(braces(str),out))
str =
'()'
out =
1×1 cell array
{'()'}
|
3 | Pass |
str = '((((()))))';
out = {'( )';
' ( ) ';
' ( ) ';
' ( ) ';
' () '}
assert(isequal(braces(str),out))
out =
5×1 cell array
{'( )'}
{' ( ) '}
{' ( ) '}
{' ( ) '}
{' () '}
str =
'((((()))))'
str =
'))))'
part =
40 32 32 32 32 32
32 40 32 32 32 32
32 32 40 32 32 32
32 32 32 40 32 32
32 32 32 32 40 41
part1 =
32 32 32 41
32 32 41 32
32 41 32 32
41 32 32 32
32 32 32 32
sout =
5×10 char array
'( )'
' ( ) '
' ( ) '
' ( ) '
' () '
out =
5×1 cell array
{'( )'}
{' ( ) '}
{' ( ) '}
{' ( ) '}
{' () '}
|
4 | Fail |
a = randi(10);
str = '';
for i = 1:a
str = [str '()'];
end
out = {str};
assert(isequal(braces(str),out))
str =
'()()'
|
5 | Pass |
str = '()(((())))()';
out = {'()( )()';
' ( ) ';
' ( ) ';
' () '}
assert(isequal(braces(str),out))
out =
4×1 cell array
{'()( )()'}
{' ( ) '}
{' ( ) '}
{' () '}
str =
'()(((())))()'
str =
')))()'
part =
40 41 40 32 32 32 32
32 32 32 40 32 32 32
32 32 32 32 40 32 32
32 32 32 32 32 40 41
part1 =
32 32 41 40 41
32 41 32 32 32
41 32 32 32 32
32 32 32 32 32
sout =
4×12 char array
'()( )()'
' ( ) '
' ( ) '
' () '
out =
4×1 cell array
{'()( )()'}
{' ( ) '}
{' ( ) '}
{' () '}
|
6 | Pass |
a = randi(10);
str = '';
for i = 1:a
str = ['(' str ')'];
end
out = {};
for i = 1:a
s = [32*ones(1,i-1) '(' 32*ones(1,2*a-2*i) ')' 32*ones(1,i-1)];
out = [out; s];
end
assert(isequal(braces(str),out))
str =
'(((((((((())))))))))'
str =
')))))))))'
part =
40 32 32 32 32 32 32 32 32 32 32
32 40 32 32 32 32 32 32 32 32 32
32 32 40 32 32 32 32 32 32 32 32
32 32 32 40 32 32 32 32 32 32 32
32 32 32 32 40 32 32 32 32 32 32
32 32 32 32 32 40 32 32 32 32 32
32 32 32 32 32 32 40 32 32 32 32
32 32 32 32 32 32 32 40 32 32 32
32 32 32 32 32 32 32 32 40 32 32
32 32 32 32 32 32 32 32 32 40 41
part1 =
32 32 32 32 32 32 32 32 41
32 32 32 32 32 32 32 41 32
32 32 32 32 32 32 41 32 32
32 32 32 32 32 41 32 32 32
32 32 32 32 41 32 32 32 32
32 32 32 41 32 32 32 32 32
32 32 41 32 32 32 32 32 32
32 41 32 32 32 32 32 32 32
41 32 32 32 32 32 32 32 32
32 32 32 32 32 32 32 32 32
sout =
10×20 char array
'( )'
' ( ) '
' ( ) '
' ( ) '
' ( ) '
' ( ) '
' ( ) '
' ( ) '
' ( ) '
' () '
out =
10×1 cell array
{'( )'}
{' ( ) '}
{' ( ) '}
{' ( ) '}
{' ( ) '}
{' ( ) '}
{' ( ) '}
{' ( ) '}
{' ( ) '}
{' () '}
|
Find the peak 3n+1 sequence value
1106 Solvers
Number of 1s in the Binary Representation of a Number
356 Solvers
220 Solvers
376 Solvers
Create logical matrix with a specific row and column sums
170 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!