Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

Heres a Python program that determines the value of n as described in the problemarrangement 00... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Smith and Roberson Business Law

Authors: Richard A. Mann, Barry S. Roberts

15th Edition

1285141903, 1285141903, 9781285141909, 978-0538473637

More Books

Students also viewed these Programming questions