Cody

Problem 2403. Best Square-Shaped Grid for Subplot

Solution 848876

Submitted on 10 Mar 2016 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
x = 1; y_correct = [1,1]; [m,n] = best_square_plot(x); assert(isequal(sort([m,n]),y_correct))

n = 1 m = 1

2   Pass
x = 3; y_correct = [2,2]; [m,n] = best_square_plot(x); assert(isequal(sort([m,n]),y_correct))

n = 2 m = 2

3   Pass
x = 4; y_correct = [2,2]; [m,n] = best_square_plot(x); assert(isequal(sort([m,n]),y_correct))

n = 2 m = 2

4   Pass
x = 5; y_correct = [2,3]; [m,n] = best_square_plot(x); assert(isequal(sort([m,n]),y_correct))

n = 3 m = 2

5   Pass
x = 11; y_correct = [3,4]; [m,n] = best_square_plot(x); assert(isequal(sort([m,n]),y_correct))

n = 4 m = 3

6   Pass
x = 26; y_correct = [5,6]; [m,n] = best_square_plot(x); assert(isequal(sort([m,n]),y_correct))

n = 6 m = 5

7   Pass
x = 111; y_correct = [11,11]; [m,n] = best_square_plot(x); assert(isequal(sort([m,n]),y_correct))

n = 11 m = 11

8   Pass
x = 4531; y_correct = [67,68]; [m,n] = best_square_plot(x); assert(isequal(sort([m,n]),y_correct))

n = 68 m = 67

Suggested Problems

More from this Author6

Community Treasure Hunt

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

Start Hunting!