Dinesman's multiple-dwelling problem: Difference between revisions
Content added Content deleted
(→{{header|Python}}: Add second solution method using Amb.) |
m (→Parsing the problem statement: Modify headings) |
||
Line 366: | Line 366: | ||
=={{header|Python}}== |
=={{header|Python}}== |
||
=== |
===By parsing the problem statement=== |
||
This example parses the statement of the problem as given and allows some variability such as the number of people, floors and constraints can be varied although the type of constraints allowed and the sentence structure is limited |
This example parses the statement of the problem as given and allows some variability such as the number of people, floors and constraints can be varied although the type of constraints allowed and the sentence structure is limited |
||
;Setup |
|||
Parsing is done with the aid of the multi-line regular expression at the head of the program. |
Parsing is done with the aid of the multi-line regular expression at the head of the program. |
||
Line 505: | Line 506: | ||
handler[groupname](txt)</lang> |
handler[groupname](txt)</lang> |
||
;Problem statement |
|||
This is not much more than calling a function on the text of the problem! |
This is not much more than calling a function on the text of the problem! |
||
<lang python>if __name__ == '__main__': |
<lang python>if __name__ == '__main__': |
||
Line 530: | Line 532: | ||
adjacent to Cooper's. Where does everyone live?""")</lang> |
adjacent to Cooper's. Where does everyone live?""")</lang> |
||
;Output |
|||
This shows the output from the original problem and then for another, slightly different problem to cover some of the variability asked for in the task. |
This shows the output from the original problem and then for another, slightly different problem to cover some of the variability asked for in the task. |
||
<pre>Floors are numbered from 1 to 5 inclusive. |
<pre>Floors are numbered from 1 to 5 inclusive. |