Write a function get_colors_straightforward (evidences) that takes a list 'evidences' and returns a tuple with (1)...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a function get_colors_straightforward (evidences) that takes a list 'evidences' and returns a tuple with (1) a sorted list of gnomes (IDs) in white hats, and (2) a sorted list of gnomes (IDs) in black hats IF no contradiction was found in each single evidence, None IF a contradiction was found. Assume that all gnome pairs in the input 'evidences' list wear same color hats, i.e. ((11, 2), 1) is not valid because gnomes 11 and 2 have different hat colors. def get_colors_straightforward(evidences) Input: a list of tuples • Returns: a tuple of two sorted lists OR None if a contradiction was found >>> evidences = [((11, 2), 0), ((3, 6), 2), ((7, 9), 2) >>> print (get_colors_straightforward (evidences)) ([3, 6, 7, 9], [2, 11]) If we now change ((3, 6), 2) to ((3, 2), 2), it will contradict ((11, 2), o), and the function returns None: >>> evidences = [((11, 2), 0), ((3, 2), 2), ((7, 9), 2) Write a function get_colors_straightforward (evidences) that takes a list 'evidences' and returns a tuple with (1) a sorted list of gnomes (IDs) in white hats, and (2) a sorted list of gnomes (IDs) in black hats IF no contradiction was found in each single evidence, None IF a contradiction was found. Assume that all gnome pairs in the input 'evidences' list wear same color hats, i.e. ((11, 2), 1) is not valid because gnomes 11 and 2 have different hat colors. def get_colors_straightforward(evidences) Input: a list of tuples • Returns: a tuple of two sorted lists OR None if a contradiction was found >>> evidences = [((11, 2), 0), ((3, 6), 2), ((7, 9), 2) >>> print (get_colors_straightforward (evidences)) ([3, 6, 7, 9], [2, 11]) If we now change ((3, 6), 2) to ((3, 2), 2), it will contradict ((11, 2), o), and the function returns None: >>> evidences = [((11, 2), 0), ((3, 2), 2), ((7, 9), 2)
Expert Answer:
Answer rating: 100% (QA)
Based on the information provided in the image you are being asked to create a Python function named getcolorsstraightforward which takes a list of ev... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
1. An auditor selected a product maintained in the finished goods Warehouse. The auditor counted the product and compare this amount what the amount in the finished goods Perpetual inventory...
-
What is the optimal time for a firm to pay its accounts payable?
-
In what additional way can you obtain the DOM addresses of individual radio buttons and checkboxes?
-
The vibratory response at the bearing of an internal combustion engine is shown in Fig. 10.45. Determine the equivalent viscous damping ratio of the system. Vibration velocity (cm/s) 17.78 15.24...
-
The Dinteman Company is an industrial machinery and equipment manufacturer with several production departments. The company employs automated and heavy equipment in its production departments....
-
You have been hired by a small business that is now expanding to 5 new locations in different cities. This can be any business of your choice, such as a coffee shop, beer/wine store, restaurant,...
-
The shareholders equity section of the balance sheet of TNL Systems Inc. included the following accounts at December 31, 2020: Shareholders Equity ...............................................($ in...
-
One end of a long rod is inserted into a furnace while the other end projects into ambient air. Under steady state the temperature of the rod is measured at two points 75mm apart and found to be 125C...
-
A bullet flying horizontally with a speed of 7 5 0 m / s bounces off a tank armor which is sloped at 4 5 degrees. Assuming that the collision is perfectly elastic and there is no friction, calculate...
-
Suppose you import a static mesh with 2066472 triangles. The mesh is a closed manifold with no holes or handles or boundary. Using the approximation seen in class derived from the Euler...
-
Click-through rates, awareness, and shareability are among the ________ Fallon Worldwide uses in the evaluation process for its advertising campaigns. themes slogans metrics concepts messages
-
You are a mid-level manager for a large accounting firm. Your task is to hire 20 new employees. Before execution, you must address the following items: Report to the district manager: Your plan to...
-
The gene for curled wings (C/c) is located nearly at the end of the long arm of chromosome 2 of Drosophila, while the gene for smooth abdomen (S/s) is nearly at the end of the short arm of the same...
-
TF Company manufactures specialist furniture. It uses a FIFO costing system to allocate costs to Finished Goods and maintains its financial records on a financial year which operates from 1 July 2017...
-
A woman at a point A on the shore of a circular lake with radius 2 mi wants to arrive at the point C diametrically opposite on the other side of the lake in the shortest possible A time. She can walk...
-
Go to the LearnChemE screencasts link for Chapter 11 (http://www.umich.edu/~elements/6e/11chap/learn-cheme-videos.html). View one of the screencast 5-to 6-minute video tutorials and list two of the...
-
Read over the problems of this chapter. Discuss with a classmate ideas for making up an original problem that uses the concepts presented in this chapter. The guidelines are given in Question Q5-3A,...
-
ICGMystery TheaterA real who done it?, see Pulp and Paper, 25 (January 1993) and also Pulp and Paper, 9 (July 1993). The outcome of the murder trial is summarized in the December 1995 issue of...
-
Water is to be used to absorb acetone from a dilute mixture with air in a tower packed with 3.5-in. metal Pall rings. Average conditions in the tower are: \[\text { Temperature }=25^{\circ}...
-
Propane gas at \(300 \mathrm{psia}\) and \(150^{\circ} \mathrm{F}\) is sent to an expansion turbine with an efficiency of \(80 \%\). What is the lowest outlet pressure that can be achieved without...
-
Liquid oxygen is stored in a tank at \(-298^{\circ} \mathrm{F}\) and 35 psia. It is to be pumped at \(100 \mathrm{lb} / \mathrm{s}\) to a pressure of \(300 \mathrm{psia}\). The liquid oxygen level in...
Study smarter with the SolutionInn App