Home / Expert Answers / Computer Science / identify-gnomes-in-different-hat-colors-in-this-question-we-start-conceptualising-gnome-evidences-pa248

(Solved): Identify gnomes in different hat colors In this question, we start conceptualising gnome evidences ...



student submitted image, transcription available below

student submitted image, transcription available below

Identify gnomes in different hat colors In this question, we start conceptualising gnome evidences as a graph, focusing on the cases where gnomes in the same tuple (i.e. a gnome pair) in the evidence can wear hats that differ in colors. The graph is represented as a dictionary. Nodes in the graph are gnome IDs, and edges connect genome-pairs who have distinct hat colors. Note: In this question, we only focus on gnome pairs with different coloured hats in evidence. Write a function make_color_mutex_graph (evidences) that takes a list of evidences as input and returns a graph (dictionary) of gnomes with different hat colors (negation_edges). The keys of the dictionary are gnome IDs, and the values contain other gnome IDs, which satisfy: - (1) the key gnome and each value gnome are in the same evidence tuple (i.e. they are gnome pairs) - (2) the key and value gnomes differ in hat colors. (Just for this question) For consistency of the output, if a dictionary value contains two or more entries, please make sure that they are sorted in the increasing order (and, therefore, each value should be a list). Sample runs: evidences print (make_color_mutex_graph(evidences)) evidences 〉> print (make_color_mutex_graph (evidences)) It corresponds to the following graph (note that the graph is undirected, and the dictionary contains two entries (directions) for each edge): evidences print (make_color_mutex_graph(evidences)) \{\} evidences >> print (make_color_mutex_graph(evidences)) \{\} There are no gnome pairs with different coloured hats. \[ \begin{array}{l} \gg>\text { evidences }=[((11,2), 1),((3,2), 1),((4,9), 2)] \\ \gg \text { print (make_color_mutex_graph(evidences)) } \\ \{11:[2], 2:[3,11], 3:[2]\} \end{array} \] It corresponds to the following graph:


We have an Answer from Expert

View Expert Answer

Expert Answer



We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe