Question: This is problem about a ship caught in a terrible storm. Although there were thirty passengers on board, plus the captain, there was only

This is problem about a ship caught in a terrible storm. Although there were thirty passengers on board, plus

This is problem about a ship caught in a terrible storm. Although there were thirty passengers on board, plus the captain, there was only enough room in the lifeboats for fifteen of them. As the captain was reluctant to leave anyone behind, she resolved to throw half of the passengers overboard before loading the boats. As it happens, half of the passengers had slighted the captain by not dining at her table during the cruise. The captain, in revenge, arranged all the passengers in a circle and began to count. Every n" passenger went overboard; naturally, the captain's friends were never chosen. Here is how the passengers were arranged (the captain's friends are shown with 0 and the enemies with 1: 0 0 0 0 0 1 1 1 1 0 0 1 1 0 1 1 1 0 0 1 1 0 1 1 0 1 0 1 0 0 Write a program to determine what the number n was. Start counting at the upper-left 0. A passenger is thrown overboard as soon as selected. Assume that the arrangement of the passengers is represented by an array; each element is an integer. Use additional arrays if you wish. Caution: Your solution should be really short (10-15 lines or so, excluding I/O). Excessively long solutions will be penalized.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres a Python program that determines the value of n as described in the problemarrangement 00... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!