Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. river crossing priests and devils in c program

river crossing priests and devils in c program

Scheduled Pinned Locked Moved C / C++ / MFC
help
1 Posts 1 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 13623484
    wrote on last edited by
    #1

    Solution:
    To arrive all the priests and devils to the other side, 6 steps are to be followed:-

    1. Firstly one devil and one priest will go to the other side. Devil will stay to the other side while priest will come back with the boat.

    2. Remaining two devils will go to the other side.
      One devil will stay to the other side while one devil will come again with the boat.
      So total two devils are on the another side of river and 3 priests and 1 devil is on the one side of the river.

    3. Now two priests will go. One priest will stay while 1 priest and 1 devil come back with the boat.

    4. Now remaining two priests will go to the other side of the river.
      Total 3 priests and 1 devil is on the one side while 2 devils is on the another side of the river.
      1 devil will come back with the boat.

    5. 2 devils will go to the other side of the river. 1 devil will stay and 1 devil will again go back with the boat.

    6. Now the remaining 2 devils will come to the other side of the river.
      All the 3 priests and 3 devils arrive safely.

    .. kindly help this project.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups