View Single Post
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 10-17-2011, 07:31 PM

Yes it does. That's not the problem.

The problem is that the function's final bit of logic (if 1 == 2 == 3 etc.) doesn't work. You need to test out all the sums individually, not all at once.

There are two ways to do this. One is to have a series of nested if/else if statements which compare each sum individually. This is the hard, sloppy way.

The other is to do the following:
-use a number list that inserts the value of each sum at its end
-use two number variables, one set to the value of the first item in the list, the other set to zero
-use an if/else inside a for all in order loop to check each number in the list against the first number variable. If they match, increment the zero variable by 1
-at the end, check to see if the zero variable now equals 8. If so, all numbers match and the square is magic

Try the latter method first.
   
Reply With Quote