The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
October 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Impressive!

Posted by Hiran on October 27, 2001 at 11:24 PM

> since i'm a bit free and didn't sleep last nite.. and i can't sleep now coz it's already 5pm.. maybe i can spend some time drawing some ugly matrix boxes here :p let's play with 3x3 matrixes ~

> step 1: (empty box)

> x.x.x
> x.x.x
> x.x.x

> step 2: (1 !!!) [middle top row]

> x.1.x
> x.x.x
> x.x.x

> step 3: (2)

> x.1.x
> x.x.x
> x.x.2

> step 4: (3)

> x.1.x
> 3.x.x
> x.x.2

> step 5: (4)

> x.1.x
> 3.x.x
> 4.x.2

> step 6: (5)

> x.1.x
> 3.5.x
> 4.x.2

> step 7: (6)

> x.1.6
> 3.5.x
> 4.x.2

> step 8: (7)

> x.1.6
> 3.5.7
> 4.x.2

> step 9: (8)

> 8.1.6
> 3.5.7
> 4.x.2

> step 10: (9)

> 8.1.6
> 3.5.7
> 4.9.2

How long did that take you Chin? Also, did you do that by yourself, or did you create your program and run it? If you did it by yourself and it pretty short time, that's impressive!! At least, to me it is...I know I can never seem to get that! Your pseudocode seems like it will work. The only problem I can see is that if that's all there is to the program for the actual logic of filling the matrix (not counting the part to finally check each row and column at the end), this won't work. After each iteration of the loop, the sums from each row, column will have to be tabulated and an "intelligent" suggestion should probably be sent as the next number to fill and where to fill it. Which means that there might actually be no need for your loop. Because if there is a method that "intelligently" calculates the next number and where to place it, a boolean array might have to be used to keep track of elements already filled up. There would probably also need to be a way of checking whether there is a point in continuing to fill the matrix or the matrix should be refilled (from the beginning). But even then, there would need to be some way of making sure that the program didn't take a million tries to give one answer.
Hiran
(I didn't see the original post, so if you remember when it was posted and the title Chin, can you let me know so I can check the original post. Thnx)




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us