haios.ro

Comentariu

alin - 30 Ian 2009

Problema celor 3 canibali si 3 misionari

Avem asa:
* definim cu M misionarii
* definim cu C canibalii
* definim cu B barca
* definim cu M1 malul initial
* definim cu M2 malul final

Si urmeaza:
I.
M1[ 3M 1C ]
B[2C]
M2[0 0]

II.
M2[0M 1C]
B[1C]
M1[3M 1C]

III.
M1[3M 0C]
B[2C]
M2[0M 1C]

IV.
M2[0M 2C]
B[1C]
M1[3M 0C]

V.
M1[1M 1C]
B[2M]
M2[0M 2C]

VI.
M2[1M 1C]
B[ 1M 1C]
M1[1M 1C]

VII.
M1[0M 2C]
B[2M]
M2[1M 1C]

VIII.
M2[3M 0C]
B[1C]
M1[0M 2C]

IX.
M1[0M 1C]
B[2C]
M2[3M 0C]

X.
M2[3M 1C]
B[1C]
M1[0M 1C]

XI.
M1[0M 0C]
B[2C]
M2[3M 1C]

XII.
M1[0M 0C]
B[0]
M2[3M 3C]

asta e rezolvarea calumea fratilor