Cody

Problem 23. Finding Perfect Squares

Solution 1902481

Submitted on 16 Aug 2019 by Daniel Cook
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))

b = logical 0 aSquared = 4 9 16 aSquaredDivided = 2.0000 4.5000 8.0000 1.3333 3.0000 5.3333 1.0000 2.2500 4.0000 b = logical 1

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

b = logical 0 aSquared = 400 441 484 529 576 625 676 729 784 841 900 aSquaredDivided = 20.0000 22.0500 24.2000 26.4500 28.8000 31.2500 33.8000 36.4500 39.2000 42.0500 45.0000 19.0476 21.0000 23.0476 25.1905 27.4286 29.7619 32.1905 34.7143 37.3333 40.0476 42.8571 18.1818 20.0455 22.0000 24.0455 26.1818 28.4091 30.7273 33.1364 35.6364 38.2273 40.9091 17.3913 19.1739 21.0435 23.0000 25.0435 27.1739 29.3913 31.6957 34.0870 36.5652 39.1304 16.6667 18.3750 20.1667 22.0417 24.0000 26.0417 28.1667 30.3750 32.6667 35.0417 37.5000 16.0000 17.6400 19.3600 21.1600 23.0400 25.0000 27.0400 29.1600 31.3600 33.6400 36.0000 15.3846 16.9615 18.6154 20.3462 22.1538 24.0385 26.0000 28.0385 30.1538 32.3462 34.6154 14.8148 16.3333 17.9259 19.5926 21.3333 23.1481 25.0370 27.0000 29.0370 31.1481 33.3333 14.2857 15.7500 17.2857 18.8929 20.5714 22.3214 24.1429 26.0357 28.0000 30.0357 32.1429 13.7931 15.2069 16.6897 18.2414 19.8621 21.5517 23.3103 25.1379 27.0345 29.0000 31.0345 13.3333 14.7000 16.1333 17.6333 19.2000 20.8333 22.5333 24.3000 26.1333 28.0333 30.0000

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

b = logical 0 aSquared = 1 aSquaredDivided = 1 b = logical 1

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

b = logical 0 aSquared = 36 100 144 196 1296 10201 aSquaredDivided = 1.0e+03 * 0.0060 0.0167 0.0240 0.0327 0.2160 1.7002 0.0036 0.0100 0.0144 0.0196 0.1296 1.0201 0.0030 0.0083 0.0120 0.0163 0.1080 0.8501 0.0026 0.0071 0.0103 0.0140 0.0926 0.7286 0.0010 0.0028 0.0040 0.0054 0.0360 0.2834 0.0004 0.0010 0.0014 0.0019 0.0128 0.1010 b = logical 1

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

b = logical 0 aSquared = 36 100 144 196 10201 aSquaredDivided = 1.0e+03 * 0.0060 0.0167 0.0240 0.0327 1.7002 0.0036 0.0100 0.0144 0.0196 1.0201 0.0030 0.0083 0.0120 0.0163 0.8501 0.0026 0.0071 0.0103 0.0140 0.7286 0.0004 0.0010 0.0014 0.0019 0.1010