Dinesman's multiple-dwelling problem: Difference between revisions
Content added Content deleted
m (→Parsing the problem statement: Modify headings) |
m (→Using the Amb operator: Modify headings) |
||
Line 552: | Line 552: | ||
</pre> |
</pre> |
||
=== |
===By using the [[Amb#Python|Amb]] operator=== |
||
In this example, the problem needs to be turned into valid Python code for use with the Amb operator. Setup is just to import Amb. |
In this example, the problem needs to be turned into valid Python code for use with the Amb operator. Setup is just to import Amb. |
||
The second set of results corresponds to this modification to the problem statement: |
The second set of results corresponds to this modification to the problem statement: |
||
<pre> |
<pre>Baker, Cooper, Fletcher, Miller, Guinan, and Smith |
||
live on different floors of an apartment house that contains |
|||
only seven floors. Guinan does not live on either the top or the third or the fourth floor. |
|||
Baker does not live on the top floor. Cooper |
|||
does not live on the bottom floor. Fletcher does not live on |
|||
either the top or the bottom floor. Miller lives on a higher |
|||
floor than does Cooper. Smith does not live on a floor |
|||
adjacent to Fletcher's. Fletcher does not live on a floor |
|||
adjacent to Cooper's. Where does everyone live</pre> |
|||
<lang python>from amb import Amb |
<lang python>from amb import Amb |
||
Line 625: | Line 625: | ||
</lang> |
</lang> |
||
;Output |
|||
<pre>Floors are numbered from 1 to 5 inclusive. |
<pre>Floors are numbered from 1 to 5 inclusive. |
||
Floor 1 is occupied by Smith |
Floor 1 is occupied by Smith |