Cody

# Problem 23. Finding Perfect Squares

Solution 144169

Submitted on 3 Oct 2012 by Peter Lindberg
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))

aa = 4 9 16 al = 3 bb = 0 0 0 0 0 0 0 0 0 b = 0 bb = -2 -1 0 0 0 0 0 0 0 bb = -2 -1 0 -7 -6 -5 0 0 0 bb = -2 -1 0 -7 -6 -5 -14 -13 -12

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

aa = Columns 1 through 10 400 441 484 529 576 625 676 729 784 841 Column 11 900 al = 11 bb = Columns 1 through 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Column 11 0 0 0 0 0 0 0 0 0 0 0 b = 0 bb = Columns 1 through 10 -380 -379 -378 -377 -376 -375 -374 -373 -372 -371 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Column 11 -370 0 0 0 0 0 0 0 0 0 0 bb = Columns 1 through 10 -380 -379 -378 -377 -376 -375 -374 -373 -372 -371 -421 -420 -419 -418 -417 -416 -415 -414 -413 -412 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Column 11 -370 -411 0 0 0 0 0 0 0 0 0 bb = Columns 1 through 10 -380 -379 -378 -377 -376 -375 -374 -373 -372 -371 -421 -420 -419 -418 -417 -416 -415 -414 -413 -412 -464 -463 -462 -461 -460 -459 -458 -457 -456 -455 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Column 11 -370 -411 -454 0 0 0 0 0 0 0 0 bb = Columns 1 through 10 -380 -379 -378 -377 -376 -375 -374 -373 -372 -371 -421 -420 -419 -418 -417 -416 -415 -414 -413 -412 -464 -463 -462 -461 -460 -459 -458 -457 -456 -455 -509 -508 -507 -506 -505 -504 -503 -502 -501 -500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Column 11 -370 -411 -454 -499 0 0 0 0 0 0 0 bb = Columns 1 through 10 -380 -379 -378 -377 -376 -375 -374 -373 -372 -371 -421 -420 -419 -418 -417 -416 -415 -414 -413 -412 -464 -463 -462 -461 -460 -459 -458 -457 -456 -455 -509 -508 -507 -506 -505 -504 -503 -502 -501 -500 -556 -555 -554 -553 -552 -551 -550 -549 -548 -547 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Column 11 -370 -411 -454 -499 -546 0 0 0 0 0 0 bb = Columns 1 through 10 -380 -379 -378 -377 -376 -375 -374 -373 -372 -371 -421 -420 -419 -418 -417 -416 -415 -414 -413 -412 -464 -463 -462 -461 -460 -459 -458 -457 -456 -455 -509 -508 -507 -506 -505 -504 -503 -502 -501 -500 -556 -555 -554 -553 -552 -551 -550 -549 -548 -547 -605 -604 -603 -602 -601 -600 -599 -598 -597 -596 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Column 11 -370 -411 -454 -499 -546 -595 0 0 0 0 0 bb = Columns 1 through 10 -380 -379 -378 -377 -376 -375 -374 -373 -372 -371 -421 -420 -419 -418 -417 -416 -415 -414 -413 -412 -464 -463 -462 -461 -460 -459 -458 -457 -456 -455 -509 -508 -507 -506 -505 -504 -503 -502 -501 -500 -556 -555 -554 -553 -552 -551 -550 -549 -548 -547 -605 -604 -603 -602 -601 -600 -599 -598 -597 -596 -656 -655 -654 -653 -652 -651 -650 -649 -648 -647 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Column 11 -370 -411 -454 -499 -546 -595 -646 0 0 0 0 bb = Columns 1 through 10 -380 -379 -378 -377 -376 -375 -374 -373 -372 -371 -421 -420 -419 -418 -417 -416 -415 -414 -413 -412 -464 -463 -462 -461 -460 -459 -458 -457 -456 -455 -509 -508 -507 -506 -505 -504 -503 -502 -501 -500 -556 -555 -554 -553 -552 -551 -550 -549 -548 -547 -605 -604 -603 -602 -601 -600 -599 -598 -597 -596 -656 -655 -654 -653 -652 -651 -650 -649 -648 -647 -709 -708 -707 -706 -705 -704 -703 -702 -701 -700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Column 11 -370 -411 -454 -499 -546 -595 -646 -699 0 0 0 bb = Columns 1 through 10 -380 -379 -378 -377 -376 -375 -374 -373 -372 -371 -421 -420 -419 -418 -417 -416 -415 -414 -413 -412 -464 -463 -462 -461 -460 -459 -458 -457 -456 -455 -509 -508 -507 -506 -505 -504 -503 -502 -501 -500 -556 -555 -554 -553 -552 -551 -550 -549 -548 -547 -605 -604 -603 -602 -601 -600 -599 -598 -597 -596 -656 -655 -654 -653 -652 -651 -650 -649 -648 -647 -709 -708 -707 -706 -705 -704 -703 -702 -701 -700 -764 -763 -762 -761 -760 -759 -758 -757 -756 -755 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Column 11 -370 -411 -454 -499 -546 -595 -646 -699 -754 0 0 bb = Columns 1 through 10 -380 -379 -378 -377 -376 -375 -374 -373 -372 -371 -421 -420 -419 -418 -417 -416 -415 -414 -413 -412 -464 -463 -462 -461 -460 -459 -458 -457 -456 -455 -509 -508 -507 -506 -505 -504 -503 -502 -501 -500 -556 -555 -554 -553 -552 -551 -550 -549 -548 -547 -605 -604 -603 -602 -601 -600 -599 -598 -597 -596 -656 -655 -654 -653 -652 -651 -650 -649 -648 -647 -709 -708 -707 -706 -705 -704 -703 -702 -701 -700 -764 -763 -762 -761 -760 -759 -758 -757 -756 -755 -821 -820 -819 -818 -817 -816 -815 -814 -813 -812 0 0 0 0 0 0 0 0 0 0 Column 11 -370 -411 -454 -499 -546 -595 -646 -699 -754 -811 0 bb = Columns 1 through 10 -380 -379 -378 -377 -376 -375 -374 -373 -372 -371 -421 -420 -419 -418 -417 -416 -415 -414 -413 -412 -464 -463 -462 -461 -460 -459 -458 -457 -456 -455 -509 -508 -507 -506 -505 -504 -503 -502 -501 -500 -556 -555 -554 -553 -552 -551 -550 -549 -548 -547 -605 -604 -603 -602 -601 -600 -599 -598 -597 -596 -656 -655 -654 -653 -652 -651 -650 -649 -648 -647 -709 -708 -707 -706 -705 -704 -703 -702 -701 -700 -764 -763 -762 -761 -760 -759 -758 -757 -756 -755 -821 -820 -819 -818 -817 -816 -815 -814 -813 -812 -880 -879 -878 -877 -876 -875 -874 -873 -872 -871 Column 11 -370 -411 -454 -499 -546 -595 -646 -699 -754 -811 -870

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

aa = 1 al = 1 bb = 0 b = 0 bb = 0

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

aa = Columns 1 through 5 36 100 144 196 1296 Column 6 10201 al = 6 bb = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 0 bb = -30 -26 -24 -22 0 65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 bb = -30 -26 -24 -22 0 65 -94 -90 -88 -86 -64 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 bb = -30 -26 -24 -22 0 65 -94 -90 -88 -86 -64 1 -138 -134 -132 -130 -108 -43 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 bb = -30 -26 -24 -22 0 65 -94 -90 -88 -86 -64 1 -138 -134 -132 -130 -108 -43 -190 -186 -184 -182 -160 -95 0 0 0 0 0 0 0 0 0 0 0 0 bb = Columns 1 through 5 -30 -26 -24 -22 0 -94 -90 -88 -86 -64 -138 -134 -132 -130 -108 -190 -186 -184 -182 -160 -1290 -1286 -1284 -1282 -1260 0 0 0 0 0 Column 6 65 1 -43 -95 -1195 0 bb = Columns 1 through 5 -30 -26 -24 -22 0 -94 -90 -88 -86 -64 -138 -134 -132 -130 -108 -190 -186 -184 -182 -160 -1290 -1286 -1284 -1282 -1260 -10195 -10191 -10189 -10187 -10165 Column 6 65 1 -43 -95 -1195 -10100

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

aa = 36 100 144 196 10201 al = 5 bb = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 0 bb = -30 -26 -24 -22 65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 bb = -30 -26 -24 -22 65 -94 -90 -88 -86 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 bb = -30 -26 -24 -22 65 -94 -90 -88 -86 1 -138 -134 -132 -130 -43 0 0 0 0 0 0 0 0 0 0 bb = -30 -26 -24 -22 65 -94 -90 -88 -86 1 -138 -134 -132 -130 -43 -190 -186 -184 -182 -95 0 0 0 0 0 bb = -30 -26 -24 -22 65 -94 -90 -88 -86 1 -138 -134 -132 -130 -43 -190 -186 -184 -182 -95 -10195 -10191 -10189 -10187 -10100