challenging task

Programming, for all ages and all languages.
Post Reply
shaz

challenging task

Post 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.
Ozguxxx

Re:challenging task

Post 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...
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:challenging task

Post 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...
Post Reply