Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

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

Elements Of Chemical Reaction Engineering

Authors: H. Fogler

6th Edition

013548622X, 978-0135486221

More Books

Students also viewed these Programming questions