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 65388

Submitted on 24 Mar 2012 by Alfonso Nieto-Castanon

Correct

69Size
Leading solution size is 59.
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
 
%%
D='<(DVD)[MTM]>';
D123='<1 (2 DVD 2)[2 MTM 2] 1>'
assert(isequal(Dyck(D),D123))
D123 =
<1 (2 DVD 2)[2 MTM 2] 1>
2
Pass
 
%%
D='<(<DVD>)[[MTM]]>';
D123='<1 (2 <3 DVD 3> 2)[2 [3 MTM 3] 2] 1>'
assert(isequal(Dyck(D),D123))
D123 =
<1 (2 <3 DVD 3> 2)[2 [3 MTM 3] 2] 1>
3
Pass
 
%%
D='<(<<DVD>>)[[MTM]]>';
D123='<1 (2 <3 <4 DVD 4> 3> 2)[2 [3 MTM 3] 2] 1>'
assert(isequal(Dyck(D),D123))
D123 =
<1 (2 <3 <4 DVD 4> 3> 2)[2 [3 MTM 3] 2] 1>