Question: 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

Write a function get_colors_straightforward (evidences) that takes a list 'evidences' and returns a tuple

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)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

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 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!