Tuesday, March 9, 2010

Magic Square (7x7)

22

31

40

49

2

11

20

175

21

23

32

41

43

3

12

175

13

15

24

33

42

44

4

175

5

14

16

25

34

36

45

175

46

6

8

17

26

35

37

175

38

47

7

9

18

27

29

175

30

39

48

1

10

19

28

175

175

175

175

175

175

175

175

175


Algorithm:
1. start - bottom middle cell
2. next square - move one right one down
3. if the landing square is filled up, use the square immediately ABOVE (since u started filling from the bottom row) the last filled square.
4. repeat step 2

repeat till all figures are filled. this is valid only for magic squares(nxn) where n= odd

No comments:

Post a Comment