Cody

# Problem 44313. "Cody" * 5 == "CodyCodyCodyCodyCody"

Solution 1306856

Submitted on 21 Oct 2017
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
assessFunctionAbsence({'regexp','regexpi','regexprep','str2num'},'FileName','mtimes.m')

2   Fail
assert(isequal("cody" * 5, "codycodycodycodycody"))

ans = 5×1 cell array {["cody" ]} {["codycody" ]} {["codycodycody" ]} {["codycodycodycody" ]} {["codycodycodycodycody"]}

Assertion failed.

3   Fail
assert(isequal("cody" * 5, "cody" * 2 + "cody" * 3))

ans = 5×1 cell array {["cody" ]} {["codycody" ]} {["codycodycody" ]} {["codycodycodycody" ]} {["codycodycodycodycody"]} ans = 5×1 cell array {["cody" ]} {["codycody" ]} {["codycodycody" ]} {["codycodycodycody" ]} {["codycodycodycodycody"]} ans = 5×1 cell array {["cody" ]} {["codycody" ]} {["codycodycody" ]} {["codycodycodycody" ]} {["codycodycodycodycody"]}

Undefined function 'plus' for input arguments of type 'cell'. Error in Test3 (line 1) assert(isequal("cody" * 5, "cody" * 2 + "cody" * 3))

4   Fail
assert(isequal(" Cody is fun! Cody is fun! Cody is fun!", 3 * " Cody is fun!"))

ans = 5×1 cell array {[ 3]} {[ 6]} {[ 9]} {[12]} {[15]}

Function 'subsindex' is not defined for values of class 'string'. Error in * (line 9) ans(b); Error in Test4 (line 1) assert(isequal(" Cody is fun! Cody is fun! Cody is fun!", 3 * " Cody is fun!"))

5   Fail
assert(isequal(" Cody 5-Year Anniversary! Cody 5-Year Anniversary!", " Cody 5-Year Anniversary!" * 2))

ans = 5×1 cell array {[" Cody 5-Year Anniversary!" ]} {[" Cody 5-Year Anniversary! Cody 5-Year Anniversary!" ]} {[" Cody 5-Year Anniversary! Cody 5-Year Anniversary! Cody 5-Year Anniversary!" ]} {[" Cody 5-Year Anniversary! Cody 5-Year Anniversary! Cody 5-Year Anniversary! Cody 5-Year Anniversary!" ]} {[" Cody 5-Year Anniversary! Cody 5-Year Anniversary! Cody 5-Year Anniversary! Cody 5-Year Anniversary! Cody 5-Year Anniversary!"]}

Assertion failed.

6   Fail
x = ["Cody";"matlab";"Simulink";"@Mathworks"] + (5:5:randi([1000,5000])); assert(isequal(x*2,x+x)) assert(isequal(x*3,x+x+x)) assert(isequal(5*x,x+x+x+x+x)) assert(isequal(101*x,x+100*x))

ans = 5×1 cell array {4×797 string} {4×797 string} {4×797 string} {4×797 string} {4×797 string}

Assertion failed.

### Community Treasure Hunt

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

Start Hunting!