You suspect that there's a spy within your group. In order to avoid precious information to...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
You suspect that there's a spy within your group. In order to avoid precious information to leak to the spy, you have come up with criteria to determine who may be a spy, You are keen to know who in your group meets those criteria. If a person has information on everyone else in the group but no one else has any information on them, that person could be a spy. For convenience, you have numbered your group members 1 to number_of_people. For example, if number_of_people is 5, then you will the members in your group labeled 1, 2, 3, 4, 5. As a result of your own intelligence efforts, you know which group members have information about each other. This is represented by has_information in the format of an array of two elements. The first person in the array has information on the second person. For example, has_information[x] = [3, 5] means that person 3 has information about person 5. Write a function: find_spy number_of_people, has_information ) that identifies the person in your group that satisfies your spy criteria. Note: the initial code in the editor uses tabs for indentation. Don't mix it with spaces. For example: If number_of_people = 2 and has_information = [[1,2]], person 1 may be the spy. The function returns 1. If number_of_people = 3 and has_information = [[1,2], [2,3]], nobody meets the spy criteria. The function returns 0. Take the following requirements into account: Validate the parameters: number_of_people should be >0 and has_information should be an array of two positive integers below or equal to number_of_people. If not, the function should return -1. If no one meets the spy criteria, return 0. You suspect that there's a spy within your group. In order to avoid precious information to leak to the spy, you have come up with criteria to determine who may be a spy, You are keen to know who in your group meets those criteria. If a person has information on everyone else in the group but no one else has any information on them, that person could be a spy. For convenience, you have numbered your group members 1 to number_of_people. For example, if number_of_people is 5, then you will the members in your group labeled 1, 2, 3, 4, 5. As a result of your own intelligence efforts, you know which group members have information about each other. This is represented by has_information in the format of an array of two elements. The first person in the array has information on the second person. For example, has_information[x] = [3, 5] means that person 3 has information about person 5. Write a function: find_spy number_of_people, has_information ) that identifies the person in your group that satisfies your spy criteria. Note: the initial code in the editor uses tabs for indentation. Don't mix it with spaces. For example: If number_of_people = 2 and has_information = [[1,2]], person 1 may be the spy. The function returns 1. If number_of_people = 3 and has_information = [[1,2], [2,3]], nobody meets the spy criteria. The function returns 0. Take the following requirements into account: Validate the parameters: number_of_people should be >0 and has_information should be an array of two positive integers below or equal to number_of_people. If not, the function should return -1. If no one meets the spy criteria, return 0.
Expert Answer:
Related Book For
Managerial accounting
ISBN: 978-0471467854
1st edition
Authors: ramji balakrishnan, k. s i varamakrishnan, Geoffrey b. sprin
Posted Date:
Students also viewed these operating system questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
"internet radios" for streaming audio, and personal video recorders and players. Describe design and evaluation processes that could be used by a start-up company to improve the usability of such...
-
Again review information about your own university. Create generalization/specialization hierarchies using the domain model class diagram notation for (1) Types of faculty, (2) Types of students, (3)...
-
Consider the following diagram of a market for one-bedroom rental apartments in a college community. a. At a rental rate of $1,000 per month, is there an excess quantity supplied, or is there an...
-
For the motor, load, and torque-speed curve shown in Figure P2.30, find the transfer function, G(s) = L (s)/E a (s). Ra N = 50 ea(t) J = 4 kg-m2 D = 8 N-m-s/rad N2 = 150 = 36 kg-m D2 = 36 N-m-s/rad...
-
Unless otherwise specified, which rule will always be processed?
-
Moontrust Bank has asked the president of Wishware Products, Inc., for a budgeted income statement and budgeted balance sheet for the quarter ended June 30. These pro forma financial statements are...
-
How would a data analyst evaluate a conference call to get a feel for the sentiment of management?
-
A local toy manufacturer is using a production e that runs 8 hours per day and produces a toy that requires a total of 7 tasks to be performed. The daily demand is 100 toys. Times of the tasks are...
-
Complete the relevant extract general ledger accounts on the disposal of machinery for each of the following independent parts. The gain on disposal or loss on disposal account is also to be shown....
-
Statutes are a primary source of law. (True/False)
-
An oral contract is an implied contract. (True/False)
-
Common law is a term that normally refers to the body of law consisting of rules of law announced in court decisions.(True/False)
-
The doctrine of stare decisis illustrates how unpredictable the law can be.(True/False)
-
Given the following data for Albert's fabricating production area: Fixed costs for one shift: $60,000.00 Unit variable cost: $7 Selling price: $12 Number of machines: $6 Number of working days in a...
-
Evenflow Power Co. is considering a new project that is a little riskier than the current operations of the company. Thus, management has decided to add an additional 1.5% to the company's overall...
-
Randy Quench manages the Science Station in Lansing, Michigan. One of the stations key attractions is a big-screen IMAX theater. As stated in the IMAX Web site, The IMAX experience is the worlds most...
-
Bruce Jaffee, the wholesaler of spices from the previous exercise, purchases most of his products on credit; he estimates that he pays 60% of his accounts payable in the month of purchase, 30% in the...
-
Frans Custom Motors uses a job-order costing system. The firm had two jobs in process at the start of the April: job no. 401 (cost : $211,250) and job no. 402 (cost: $53,400). The following...
-
An antenna far field radiation pattern is independent of \(\phi\) and the varies versus \(\theta\) as follows: Compute the directivity. 1 0030 0.5 60 0120 1 F(0, 0) = 150 0180 2 0 30 0 60 0 120 0150
-
An antenna far field radiation pattern is independent of \(\phi\) and the varies versus \(\theta\) as follows: \[ F(\theta, \phi)=\left\{\begin{array}{rr} 1 & \frac{\pi}{2}-\alpha \leq \theta \leq...
-
A certain antenna has a radiation intensity given by \[ F(\theta, \phi)=\left\{\begin{array}{ll} \left|\cos ^{n} \thetaight| & 0 \leq \theta \leq(\pi / 2) \\ 0 & (\pi / 2) \leq \theta \leq \pi...
Study smarter with the SolutionInn App