Cody

Problem 1686. Generate a melodic contour string matrix

Solution 1941776

Submitted on 18 Sep 2019
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
str = '*rrr'; melody = '*-*-*-*'; assert(strcmp(parsons(str),melody))

*-*-*-*

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

Unable to perform assignment because the size of the left side is 3-by-2 and the size of the right side is 2-by-3. Error in parsons/incidi (line 14) m(level+(0:2),end+(1:2)) = [' \ '; ' *']; Error in parsons (line 4) m = incidi(m,str(i)); Error in Test2 (line 5) assert(strcmp(parsons(str),melody))

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

Unrecognized function or variable 'u'. Error in parsons/incidi (line 15) case u Error in parsons (line 4) m = incidi(m,str(i)); Error in Test3 (line 9) assert(strcmp(parsons(str),melody))

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

Unrecognized function or variable 'u'. Error in parsons/incidi (line 15) case u Error in parsons (line 4) m = incidi(m,str(i)); Error in Test4 (line 7) assert(strcmp(parsons(str),melody))

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

Unrecognized function or variable 'u'. Error in parsons/incidi (line 15) case u Error in parsons (line 4) m = incidi(m,str(i)); Error in Test5 (line 13) assert(strcmp(parsons(str),melody))