Cody

# Problem 1461. Duplicate a character

Solution 3435238

Submitted on 27 Oct 2020
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   Fail
str = 'b';n=5 y_correct = 'bbbbb'; assert(isequal(duplicate_char(str,n),y_correct))

n = 5

Error using strings Array must be numeric or logical. Error in duplicate_char (line 2) y = strings(str,n) Error in Test1 (line 3) assert(isequal(duplicate_char(str,n),y_correct))

2   Fail
str = 's';n=1 y_correct = 's'; assert(isequal(duplicate_char(str,n),y_correct))

n = 1

Error using strings Array must be numeric or logical. Error in duplicate_char (line 2) y = strings(str,n) Error in Test2 (line 3) assert(isequal(duplicate_char(str,n),y_correct))

3   Fail
str = 'b';n=10 y_correct = 'bbbbbbbbbb'; assert(isequal(duplicate_char(str,n),y_correct))

n = 10

Error using strings Array must be numeric or logical. Error in duplicate_char (line 2) y = strings(str,n) Error in Test3 (line 3) assert(isequal(duplicate_char(str,n),y_correct))

4   Fail
str = 'b';n=0 y_correct = ''; assert(isequal(duplicate_char(str,n),y_correct))

n = 0

Error using strings Array must be numeric or logical. Error in duplicate_char (line 2) y = strings(str,n) Error in Test4 (line 3) assert(isequal(duplicate_char(str,n),y_correct))

5   Fail
str = '?';n=2 y_correct = '??'; assert(isequal(duplicate_char(str,n),y_correct))

n = 2

Error using strings Array must be numeric or logical. Error in duplicate_char (line 2) y = strings(str,n) Error in Test5 (line 3) assert(isequal(duplicate_char(str,n),y_correct))

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!