Cody

Problem 44436. Find the largest number

Solution 2689169

Submitted on 13 Jul 2020 by Alexander
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
filetext = fileread('largest.m'); assert(isempty(strfind(filetext, 'regexp')),'regexp hacks are forbidden') assert(isempty(strfind(filetext, 'max')),'max() forbidden') assert(isempty(strfind(filetext, 'min')),'min() forbidden') assert(isempty(strfind(filetext, 'sort')),'sort() forbidden') assert(isempty(strfind(filetext, 'unique')),'unique() forbidden')

2   Pass
a = 4; b = 7; c = 1; d = 6; x_correct = 7; assert(isequal(largest(a, b, c, d),x_correct))

m = 7 m = 6 m = 7 x = 7

3   Pass
a = 1; b = 1; c = 1; d = 1; x_correct = 1; assert(isequal(largest(a, b, c, d),x_correct))

m = 1 m = 1 m = 1 x = 1

4   Pass
a = 4; b = 3; c = 2; d = 1; x_correct = 4; assert(isequal(largest(a, b, c, d),x_correct))

m = 4 m = 2 m = 4 x = 4

5   Pass
a = 1; b = 2; c = 3; d = 4; x_correct = 4; assert(isequal(largest(a, b, c, d),x_correct))

m = 2 m = 4 m = 4 x = 4

6   Pass
a = 1; b = 1; c = 3; d = 5; x_correct = 5; assert(isequal(largest(a, b, c, d),x_correct))

m = 1 m = 5 m = 5 x = 5

7   Pass
a = 3; b = 3; c = 2; d = 4; x_correct = 4; assert(isequal(largest(a, b, c, d),x_correct))

m = 3 m = 4 m = 4 x = 4

8   Pass
a = 2; b = 3; c = 1; d = 6.5; x_correct = 6.5; assert(isequal(largest(a, b, c, d),x_correct))

m = 3 m = 6.5000 m = 6.5000 x = 6.5000

9   Pass
a = 3; b = 3; c = 3; d = 9; x_correct = 9; assert(isequal(largest(a, b, c, d),x_correct))

m = 3 m = 9 m = 9 x = 9

10   Pass
a = 5; b = 3; c = 3; d = 9; x_correct = 9; assert(isequal(largest(a, b, c, d),x_correct))

m = 5 m = 9 m = 9 x = 9

11   Pass
a = 3; b = 3; c = 3; d = 1; x_correct = 3; assert(isequal(largest(a, b, c, d),x_correct))

m = 3 m = 3 m = 3 x = 3

12   Pass
a = 3; b = 3; c = 9; d = 9; x_correct = 9; assert(isequal(largest(a, b, c, d),x_correct))

m = 3 m = 9 m = 9 x = 9

13   Pass
a = 3; b = 3; c = 1; d = 1; x_correct = 3; assert(isequal(largest(a, b, c, d),x_correct))

m = 3 m = 1 m = 3 x = 3

Suggested Problems

More from this Author25

Community Treasure Hunt

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

Start Hunting!