/* Left/right hand words in Picat. What words can be written with only left/right hand on a keyboard? This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ main => go. go => File = "unixdict.txt", Words = read_file_lines(File), LeftChars = "qwertasdfgzxcvb", RightChars = "yuiophjklnm", Left = [], Right = [], foreach(Word in Words,Len=Word.len, Len > 4) if classify_word(Word,LeftChars) then Left := Left ++ [[Len,Word]] elseif classify_word(Word,RightChars) then Right := Right ++ [[Len,Word]] end end, println("Left words:"), println(Left.sort()), println(len=Left.len), nl, println("Right words:"), println(Right.sort()), println(len=Right.len), nl. classify_word(Word,Chars) => Found = true, foreach(W in Word, Found == true) if not member(W,Chars) then Found := false end end, Found = true.