Page 1 of 1

challenging task

Posted: Fri May 21, 2004 12:31 am
by shaz
i want to write a program in assembly language in which user gives an even number (suppose 4),the program makes a matrix of rows and columns equal to number given by user.

this n*n matrix should be in such form that the sum of elements of any row or column or any diagnul should be same and no number should be repeated in matrix.

e.g

x1 x2 x3 x4
x5 x6 x7 x8
x9 x10 x11 x12
x13 x14 x15 x16

then


x1+x2+x3+x4=x13+x14+x15+x16=x3+x7+x11+x15=x13+x10 +x7+x4

so you can see if add any row or column or diagnul,the answer is same

i've tried the whole day without any success.

please tell me what will be the logic behind it.

Re:challenging task

Posted: Fri May 21, 2004 1:05 am
by Ozguxxx
Read some linear algebra books and -I hope- you can find the answer. Since you will most probably have inifinite number of solutions, you can find a matrix that satisfies the nonrepeated elements constraint...

Re:challenging task

Posted: Fri May 21, 2004 7:20 am
by Candy
for odd numbers there's a simple algorithm. I'm not going to tell you, but here's an example 11x11 display. You can figure it out can't you?

PS it's a bitmap (.bmp) but the board doesn't like .bmp so it'll from now on be called a JPEG-called-bitmap. Some people have lame methods to prevent hacking...

Re:challenging task

Posted: Fri May 21, 2004 5:27 pm
by nebula