Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Help needed in writing this python program?
Bridge Crossing at Night puzzle: A group of five people, who have one flashlight,need to cross a rickety bridge at night. A maximum of three persons can cross the
bridge at one time, and any party that crosses(either two or three ) must have the flashlight with them. The flashlight must be walked back and forth; it cannot be
thrown. Person A takes 1.5minutes to cross the bridge,Person B takes 2minutes, Person C takes 4.25minutes, Person D takes 5minutes, and person E takes 9minutes.
At least, two persons must walk together at the slower person's pace
c)write a program segment that determine the total amount of time required for all persons to cross the bridge.
simulate the program and determine if the program will ever terminate stating reasons
d) Assume the number of persons is increased to 6 and the sixth person, F, takes 11minutes to cross the bridge
Do you envisage programmable solution? If solutoin exist for this problem, write a program segment that compute the total time required for all persons to cross
the bridge. Otherwise, provide reasons for no solution, state what will happen to your program and suggest remedy
1 Answer
- husoskiLv 77 years ago
I don't think anyone is going to write your assignment for you, but I've been wrong about this before. So, if you are unlucky then someone might.
I say "unlucky" because you never get a second chance to solve a puzzle on your own. As a hint, though, think about who you want carrying the flashlight. Will it be the same person on the second forward trip as the first?
You can write an exhaustive search to find the best solution without any analysis, but that's more complicated. Fun to try, though.