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 270371

Submitted on 1 Jul 2013 by J.R.! Menzinger

Correct

113Size
Leading solution size is 72.
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
 
%%
str = '*rrr';
melody = '*-*-*-*';
assert(strcmp(parsons(str),melody))

                    
2
Pass
 
%%
str = '*du';
melody = ['*   *'
          ' \ / '
          '  *  '];
assert(strcmp(parsons(str),melody))

                    
3
Pass
 
%%
str = '*ruuddduur';
melody = ['      *            '
          '     / \           '
          '    *   *       *-*'
          '   /     \     /   '
          '*-*       *   *    '
          '           \ /     '
          '            *      '];
assert(strcmp(parsons(str),melody))

                    
4
Pass
 
%%
str = '*rududdrudud';
melody = ['    *   *              '
          '   / \ / \             '
          '*-*   *   *     *   *  '
          '           \   / \ / \ '
          '            *-*   *   *'];
assert(strcmp(parsons(str),melody))

                    
5
Pass
 
%%
str = '*rururddrdrdrd';
melody = ['        *-*                '
          '       /   \               '
          '    *-*     *              '
          '   /         \             '
          '*-*           *-*          '
          '                 \         '
          '                  *-*      '
          '                     \     '
          '                      *-*  '
          '                         \ '
          '                          *'];
assert(strcmp(parsons(str),melody))