/* Four Word problem in Picat. From the F1 model http://www.f1compiler.com/samples/FourWord.f1.html """ FourWord problem: place these letters: a,b,e,l,n,o,p,p,s,t into the blank spaces to create four-letter words down and accross. +---+---+---+---+ | | o | | | +---+---+---+---+ | | | l | e | +---+---+---+---+ | | | a | n | +---+---+---+---+ | l | | | | +---+---+---+---+ """ This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import util. main => go. go ?=> M = [ [ _, 'o', _, _], [ _, _, 'l', 'e'], [ _, _, 'a', 'n'], ['l', _, _, _] ], MT = M.transpose(), File = "unixdict.txt", Words = [W : W in read_file_lines(File), length(W) = 4], foreach(I in 1..M.len) member(M[I],Words), member(MT[I],Words) end, foreach(Row in M) println(Row) end, nl, fail, nl. go => true.