Originally posted by Vlado Zajac:
Logical programming (I have used GNU Prolog and its constraint solver for very similar problem) seems to be more suitable than procedural programming (Java, C, ...) for this kind of puzzles.
It is possible to translate this problem into a the notation of symbolic logic and solve it by appropriate method ,but this seems to be cumber some. On the other hand ,it is difficult to grasp the problem's logical structure without some sort of notational aid. The most convenient device to use is a matrix with vacant cells for all possible pairings of the elements in each set. In this case there are two sets. Hence two such matrices are required. Each cell is to be marked with "1" to indicate that combination is valid, or "0" to indicate that it is ruled out by the premises. As for example The last premise obviously eliminates the possibilty that Smith is the fireman so, place a ''0" in the upper right corner cell of the matrix at left.
(pl note that use truthtable doesn't solve th problem either.
Though basically this problem may be solved under prolog, the same can be tried by using two matrices and try to do the placing task in the respective cells in the matrix as indicated above. That is why a Java coded
Program viz doublearray. java has been given for a modification that calls for a method replacing
the aveg find method (in the prog shown) in order to get the solution for the problem.
It is here that gave me a scope to pose it especially those who are familiar with the creating
Matrix methods. as also we are within our limits if we solve the same with through java language since
We are in Java Lobby Forem and so the uses of JavaLang .
Thanks.Can any body fetch the solution...
As Always
C.R.Muthukumar