cannibals problem... 
Author Message
 cannibals problem...

I am trying to implement a program to solve the {*filter*}s and missionaries
problem. Have someone already done this program ?? If yes, could you send me
for analysing ???


Fri, 30 Nov 2001 03:00:00 GMT  
 cannibals problem...

Quote:

> I am trying to implement a program to solve the {*filter*}s and
> missionaries problem. Have someone already done this program ??

Someone did this program on an electronic computer in the
1950s. Possibly even earlier.

Quote:
> If yes, could you send me for analysing ???

Here's a version from 1976 in Motorola assembler for your "analysis".

http://www.*-*-*.com/

Christopher



Sat, 01 Dec 2001 03:00:00 GMT  
 cannibals problem...

Quote:

> I am trying to implement a program to solve the {*filter*}s and
> missionaries problem. Have someone already done this program ?? If
> yes, could you send me for analysing ???

;; Here's a solution in a declarative formalism:

(defun print-solution (solution &optional (stream t))
   (format stream "~{~A~%~}" solution))

(defparameter *{*filter*}s-solution*
  '("Start"
    "1 {*filter*} and 1 Missionary cross river"
    "1 Missionary returns"
    "2 {*filter*}s cross river"
    "1 {*filter*} returns"
    "2 Missionaries cross river"
    "1 {*filter*} and 1 Missionary return (!)"
    "2 Missionaries cross river"
    "1 {*filter*} returns"
    "2 {*filter*}s cross river"
    "1 {*filter*} returns"
    "2 {*filter*}s cross river"
    "Done"))

(print-solution *{*filter*}s-solution*)

;; An iterative version would look like:

(defun print-solution-iterative (solution &optional (stream t))
  (dolist (phrase solution)
    (format stream "~A~%" phrase)))

;; An iterative version using loop would look like:

(defun print-solution-loop (solution &optional (stream t))
  (loop for phrase in solution
        do (format stream "~A~%" phrase)))

;; A mapping solution would look like:

(defun print-solution-mapping (solution &optional (stream t))
  (mapc #'(lambda (phrase) (format stream "~A~%" phrase)) solution)
  nil)

--



Sat, 01 Dec 2001 03:00:00 GMT  
 cannibals problem...
Thomas A. Russ schrieb:

Quote:
> (defparameter *{*filter*}s-solution*
>   '("Start"
>     "1 {*filter*} and 1 Missionary cross river"
>     "1 Missionary returns"

At this point, there are 3 missionaries and only 2
{*filter*}s on the first side of the river. This will
allow the missionaries to baptize the {*filter*}s,
which should be avoided :-)

Ralf



Mon, 03 Dec 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Missionaries Cannibals Problem... kinda stuck on an idea

2. Missionary and Cannibal Problem

3. Depth-first search/Missionary & Cannibal problem

4. prolog Cannibals and Missionaries

5. missionaries & cannibals

6. cannibals and missionaries ... help

7. Help! cannibal and missionary problem in LISP or C++

8. Problems, problems, problems

9. Eiffel Problems, Problems, Problems

10. Finn Idiom problems and Re: {rho} problem

11. Combinatorial Problem [ & a new Combinatorial Problem ]

12. Database problem/Memory problem??

 

 
Powered by phpBB® Forum Software