Cody

# Problem 23. Finding Perfect Squares

Solution 2869418

Submitted on 23 Aug 2020 by Aniqah Beharry
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
a = [2 3 4]; assert(isequal(isItSquared(a),true))

ans = 2 3 4 i = 1 3 i = 3 check = logical 0 og = 2 sq = 4 issq = logical 1 check = 1×2 logical array 0 1 og = 3 sq = 9 issq = logical 0 check = 1×3 logical array 0 1 0 og = 4 sq = 16 issq = logical 0 check = 1×4 logical array 0 1 0 0 b = logical 1

2   Pass
a = [20:30]; assert(isequal(isItSquared(a),false))

ans = 20 21 22 23 24 25 26 27 28 29 30 i = 1 11 i = 11 check = logical 0 og = 20 sq = 400 issq = logical 0 check = 1×2 logical array 0 0 og = 21 sq = 441 issq = logical 0 check = 1×3 logical array 0 0 0 og = 22 sq = 484 issq = logical 0 check = 1×4 logical array 0 0 0 0 og = 23 sq = 529 issq = logical 0 check = 1×5 logical array 0 0 0 0 0 og = 24 sq = 576 issq = logical 0 check = 1×6 logical array 0 0 0 0 0 0 og = 25 sq = 625 issq = logical 0 check = 1×7 logical array 0 0 0 0 0 0 0 og = 26 sq = 676 issq = logical 0 check = 1×8 logical array 0 0 0 0 0 0 0 0 og = 27 sq = 729 issq = logical 0 check = 1×9 logical array 0 0 0 0 0 0 0 0 0 og = 28 sq = 784 issq = logical 0 check = 1×10 logical array 0 0 0 0 0 0 0 0 0 0 og = 29 sq = 841 issq = logical 0 check = 1×11 logical array 0 0 0 0 0 0 0 0 0 0 0 og = 30 sq = 900 issq = logical 0 check = 1×12 logical array 0 0 0 0 0 0 0 0 0 0 0 0 b = logical 0

3   Pass
a = ; assert(isequal(isItSquared(a),true))

ans = 1 i = 1 1 i = 1 check = logical 0 og = 1 sq = 1 issq = logical 1 check = 1×2 logical array 0 1 b = logical 1

4   Pass
a = [6 10 12 14 36 101]; assert(isequal(isItSquared(a),true))

ans = 6 10 12 14 36 101 i = 1 6 i = 6 check = logical 0 og = 6 sq = 36 issq = logical 1 check = 1×2 logical array 0 1 og = 10 sq = 100 issq = logical 0 check = 1×3 logical array 0 1 0 og = 12 sq = 144 issq = logical 0 check = 1×4 logical array 0 1 0 0 og = 14 sq = 196 issq = logical 0 check = 1×5 logical array 0 1 0 0 0 og = 36 sq = 1296 issq = logical 0 check = 1×6 logical array 0 1 0 0 0 0 og = 101 sq = 10201 issq = logical 0 check = 1×7 logical array 0 1 0 0 0 0 0 b = logical 1

5   Pass
a = [6 10 12 14 101]; assert(isequal(isItSquared(a),false))

ans = 6 10 12 14 101 i = 1 5 i = 5 check = logical 0 og = 6 sq = 36 issq = logical 0 check = 1×2 logical array 0 0 og = 10 sq = 100 issq = logical 0 check = 1×3 logical array 0 0 0 og = 12 sq = 144 issq = logical 0 check = 1×4 logical array 0 0 0 0 og = 14 sq = 196 issq = logical 0 check = 1×5 logical array 0 0 0 0 0 og = 101 sq = 10201 issq = logical 0 check = 1×6 logical array 0 0 0 0 0 0 b = logical 0

### Community Treasure Hunt

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

Start Hunting!