Code Monkey home page Code Monkey logo

missionaries-and-cannibals's Introduction

Missionaries and Cannibals

Build Status

Solves the missionaries and cannibals problem with iterative deepening search.

The problem is as follows:

Three missionaries and three cannibals are on one side of a river, along with a boat that can hold one or two people.

initial state

Find a way to get everyone to the other side, without ever leaving a group of missionaries on one side outnumbered by the cannibals.

The current state is represented with a list [a, b, c]. This list represents the number of missionaries on the wrong side, cannibals on the wrong side, and whether the boat is on the wrong side. Initially all the missionaries, cannibals, and the boat are on the wrong side of the river. The list representing the initial state is [3, 3, 1], while the list representing the goal state is [0, 0, 0].

The program outputs the 11 step path to the goal state to the screen.

How to Run

python main.py

Please run with Python 3. The program was written with Python 3.6.3.

missionaries-and-cannibals's People

Contributors

gbroques avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.