Just one last puzzle 
Author Message
 Just one last puzzle

Just one more puzzle and then I really MUST get some work done today.

Arrange the seven letter words words (below) to fit onto the following
crossword grid.

                1   2   3
                d   d   d
                _   _   _
   1 across   _ _ _ _ _ _ _
                _   _   _
   2 across   _ _ _ _ _ _ _
                _   _   _
   3 across   _ _ _ _ _ _ _
                _   _   _

words:
        abalone
        abandon
        enhance
        anagram
        connect
        elegant

Solution follows

% Crossword

% The representation of the puzzle is a representation of six words.  Each
% word is represented as a term word/7; each argument represents one
% letter of the word.  The ordering of the words should help to reduce the
% search space; none of the letters of 1 across appear in 2 across, but
% one appears in 1 down, so 1 down is tried next; and so on.

% Represent as variables the letters at the points of intersection:
%
%        _   _   _
%      _ A _ B _ C _
%        _   _   _
%      _ D _ E _ F _
%        _   _   _
%      _ G _ H _ I _
%        _   _   _

% Two solutions are found because of the symmetry of the puzzle.

solve(Words) :-
        Words = [
                        word(_,A,_,B,_,C,_),            % 1 across
                        word(_,A,_,D,_,E,_),            % 1 down
                        word(_,D,_,F,_,G,_),            % 2 across
                        word(_,B,_,F,_,H,_),            % 2 down
                        word(_,E,_,H,_,I,_),            % 3 across
                        word(_,C,_,G,_,I,_)             % 3 down
                ],
        search([],Words).

search(_,[]).

search(So_far,[W|Words]) :-
        candidate(W),
        \+ member(W,So_far),
        search([W|So_far],Words).

member(X,[X|_]).
member(X,[_|T]) :-
        member(X,T).

candidate(word(a,b,a,l,o,n,e)).
candidate(word(a,b,a,n,d,o,n)).
candidate(word(a,n,a,g,r,a,m)).
candidate(word(c,o,n,n,e,c,t)).
candidate(word(e,l,e,g,a,n,t)).
candidate(word(e,n,h,a,n,c,e)).

--
Son, all the pretty, intelligent, healthy     # Ken Johnson, AIAI, Edinburgh
young women are taken. It's a basic rule of   # tel 031 650 2756, fax 650 6513
the universe, and if you don't like it, go    #
somewhere else.        -- my dad  1906-1992   # Human Brain Inside



Fri, 18 Aug 1995 22:37:33 GMT  
 Just one last puzzle
%%% I'd prefer the following solution, because it is mine :-)
%%% ehm no, because it does not use negation.

solve(Words) :-
        Words = [
                        word(_,A,_,B,_,C,_),            % 1 across
                        word(_,A,_,D,_,E,_),            % 1 down
                        word(_,D,_,F,_,G,_),            % 2 across
                        word(_,B,_,F,_,H,_),            % 2 down
                        word(_,E,_,H,_,I,_),            % 3 across
                        word(_,C,_,G,_,I,_)             % 3 down
                ],
        search(Words,[word(a,b,a,l,o,n,e),
                      word(a,b,a,n,d,o,n),
                      word(a,n,a,g,r,a,m),
                      word(c,o,n,n,e,c,t),
                      word(e,l,e,g,a,n,t),
                      word(e,n,h,a,n,c,e)
                     ]).

search( [],[]).
search( [W|Words], Candidates) :-
        select( Candidates, W, Candidates1),
        search( Words, Candidates1).

select( [X|L], X, L).
select( [Y|L], X, [Y|L1]) :- select( L,X,L1).

/*
--------------------------------------------------------------------------
Bernhard Pfahringer
Austrian Research Institute for  

Schottengasse 3                  Fax:   (+43 1) 532-0652
A-1010 Vienna, Austria           Phone: (+43 1) 533-6112
*/



Sat, 19 Aug 1995 02:02:44 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. One of many little puzzles.. puzzle1

2. puzzle: one-liner test for threads?

3. cancel that last one!

4. one last VW newbie prob.

5. TILE Forth RELEASE: package 7 (THE LAST ONE)

6. Clipper 5.2e crashes when last field of DBF file has one character name

7. Gwydion URL, one last time...

8. not as easy as the last one...

9. One more(last) question about DOS FAT.

10. One more(last) question about DOS FAT.

11. One more(last) question about DOS FAT.

12. One more(last) question about DOS FAT.

 

 
Powered by phpBB® Forum Software