1 ! Copyright (C) 2019-2020 KUSUMOTO Norio.
2 ! See https://factorcode.org/license.txt for BSD license.
4 ! Zebra Puzzle: https://rosettacode.org/wiki/Zebra_puzzle
7 IN: logic.examples.zebra
9 LOGIC-PREDS: houseso neighboro zebrao watero nexto lefto ;
10 LOGIC-VARS: Hs A B Ls X Y ;
11 SYMBOLS: red blue green white yellow ;
12 SYMBOLS: english swede dane norwegian german ;
13 SYMBOLS: dog cat birds horse zebra ;
14 SYMBOLS: tea coffee beer milk water ;
15 SYMBOLS: pall-mall dunhill blue-master prince blend ;
16 TUPLE: house color nationality drink smoke pet ;
20 L{ T{ house f __ norwegian __ __ __ } ! #10
21 T{ house f blue __ __ __ __ } ! #15
22 T{ house f __ __ milk __ __ } ! #9
25 { membero T{ house f red english __ __ __ } Hs } ! #2
26 { membero T{ house f __ swede __ __ dog } Hs } ! #3
27 { membero T{ house f __ dane tea __ __ } Hs } ! #4
28 { lefto T{ house f green __ __ __ __ } T{ house f white __ __ __ __ } Hs } ! #5
29 { membero T{ house f green __ coffee __ __ } Hs } ! #6
30 { membero T{ house f __ __ __ pall-mall birds } Hs } ! #7
31 { membero T{ house f yellow __ __ dunhill __ } Hs } ! #8
32 { nexto T{ house f __ __ __ blend __ } T{ house f __ __ __ __ cat } Hs } ! #11
33 { nexto T{ house f __ __ __ dunhill __ } T{ house f __ __ __ __ horse } Hs } ! #12
34 { membero T{ house f __ __ beer blue-master __ } Hs } ! #13
35 { membero T{ house f __ german __ prince __ } Hs } ! #14
36 { nexto T{ house f __ __ water __ __ } T{ house f __ __ __ blend __ } Hs } ! #16
37 { membero T{ house f __ X water __ __ } Hs }
38 { membero T{ house f __ Y __ __ zebra } Hs }
42 { appendo __ L{ A B . __ } Ls } ;;
43 { appendo __ L{ B A . __ } Ls }
46 { lefto A B Ls } { appendo __ L{ A B . __ } Ls } rule