Jump to content

Dinesman's multiple-dwelling problem: Difference between revisions

m
m (→‎Using the Amb operator: Modify headings)
Line 552:
</pre>
 
===UsingBy 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.
 
The second set of results corresponds to this modification to the problem statement:
<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
Line 625:
</lang>
 
====;Output====
 
<pre>Floors are numbered from 1 to 5 inclusive.
Floor 1 is occupied by Smith
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.