Missionaries Games Missionaries And Cannibals In Prolog

To a new website, it does not have much your attention, but I wish you could give me a favour in advertising, introducing it to people by sharing its link for your friends, family members who own games PC through out Facebook, twitter and other websites. Download game basara 2 pc repack torrent. It created with the purpose is to share free full games PC for all of you. At the present, more than 8888 free full games PC are loaded on the website and it has still been in process of building, finishing the contents, so I hope that most of free full games PC could be updated as soon as possible.
Marianafranco / missionaries-and-cannibals. Pull requests 0. Projects 0 Insights Permalink. Find file Copy path missionaries-and-cannibals / prolog / missionaries_and_cannibals.pl. 34b2a7d Apr 17, 2012. Marianafranco first commit. 1 contributor. Users who have contributed to this file. Marianafranco Raw Blame History.
In the: Three missionaries and three cannibals must cross a river using a boat which can carry at most two people, under the constraint that, for both banks and the boat, if there are missionaries present on the bank (or the boat), they cannot be outnumbered by cannibals (if they were, the cannibals would eat the missionaries). The boat cannot cross the river by itself with no people on board. For this puzzle has 11 one-way trips. What should be the strategy to solve this puzzle for M missionaries and C cannibals, given that M is not less than C, or else the puzzle wouldn't be solvable. Let's define a b * c d to represent the state of the river at any given time: a missionaries and b cannibals on the left, c missionaries and d cannibals on the right, and * being if the boat is on the right. The problem starts out in the state M C M C.
For the case of M being more than C, here's an algorithm to transfer 1 missionary and 1 cannibal at a time: • Bring 1 missionary and 1 cannibal over. ( M-1 C-1 > 1 1) • Bring the cannibal back. ( M-1 C C, M-1 >= C, as required.) • Bring 1 missionary and 1 cannibal over again. ( M-2 C-1 > 2 1) • Bring a missionary back. ( M-1 C-1 3, because the solution for M = 3 already depends on the fact that you can have only cannibals on one side and they won't be able to do anything to the missionaries no matter how many there are on one side. The part of the solution where this applies looks something like this: • 3 1 2 2 • 2 2 3 1 There's no way to get a similar arrangement for anything greater than three, because you can't send enough missionaries at once to balance out the rest of the cannibals. For the case of more M than C it becomes trivial as a canibal can run the ferry after some initial setup.

It starts with 1 M and 1C in the boat with C+1 M on the original shore. The M takes the boat back and gets another M, leaving C Ms on the original shore, The Ms get to the other side and send the C back with the boat. The C can now ferry alternating C's and Ms without issue. The Ms will always outnumber the number left on either shore.
If M is 2 or more higher than C, then M can actually run the boat as well since they can start with 2 Ms in the boat and keep a higher number on both shores simultaneously while also operating the boat. Here's a foolproof solution: One missionary and one cannibal cross to the other side, The cannibal gets out and the missionary comes back Missionary gets out of the boat, two cannibals get in and cross One cannibals gets out and the other cannibal goes back The cannibal gets out and two missionaries get in and cross One missionary gets out, the other missionary stays in the boat and one cannibal gets in and goes back. The cannibal gets out and two missionaries get in and cross The two missionaries get down and the cannibal gets in the boat and goes back One cannibal gets in and they both cross but only one cannibal gets out The other cannibal in the boat goes back, collects the other cannibal, they cross and they get out. And you should have won. • Two cannibals go across (leaving one cannibal and three missionaries on home side) • One cannibal stays and one returns (leaving one cannibal on other side) • Cannibal and Missionary go across. • Missionary stays and cannibal returns (leaving one missionary and one cannibal on other side) • Both two remaining Missionaries go across (leaving two cannibals at home) • The one cannibal on other side returns to home (leaving three missionaries on other side) • Two cannibals go across to other side. • One returns.