Files

2.2 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
6557716aadbd2d9c42c0e69a Step 14 20 step-14

--description--

Add one last node, D, which is connected with A and C. Modify your dictionary to represent this structure. Again, use a list to represent multiple connections.

--hints--

Your dictionary should have 4 keys called A, B, C, and D.

({ test: () => assert(__pyodide.runPython(`
    graph = __locals.get("my_graph")
    key_list = ["A", "B", "C", "D"]
    len(graph) == 4 and all(key in graph for key in key_list)
  `))
})

my_graph["A"] should be a list.

({ test: () => assert(__pyodide.runPython(`
    graph = __locals.get("my_graph")
    type(graph["A"]) is list
  `))
})

my_graph["A"] should be a list containing B and D.

({ test: () => assert(__pyodide.runPython(`
    graph = __locals.get("my_graph")
    len(graph["A"]) == 2 and "B" in graph["A"] and "D" in graph["A"]
  `))
})

my_graph["B"] should be a list.

({ test: () => assert(__pyodide.runPython(`
    graph = __locals.get("my_graph")
    type(graph["B"]) is list
  `))
})

my_graph["B"] should be a list containing A and C.

({ test: () => assert(__pyodide.runPython(`
    graph = __locals.get("my_graph")
    len(graph["B"]) == 2 and "A" in graph["B"] and "C" in graph["B"]
  `))
})

my_graph["C"] should be a list.

({ test: () => assert(__pyodide.runPython(`
    graph = __locals.get("my_graph")
    type(graph["C"]) is list
  `))
})

my_graph["C"] should be a list containing B and D.

({ test: () => assert(__pyodide.runPython(`
    graph = __locals.get("my_graph")
    len(graph["C"]) == 2 and "B" in graph["C"] and "D" in graph["C"]
  `))
})

my_graph["D"] should be a list.

({ test: () => assert(__pyodide.runPython(`
    graph = __locals.get("my_graph")
    type(graph["D"]) is list
  `))
})

my_graph["D"] should be a list containing A and C.

({ test: () => assert(__pyodide.runPython(`
    graph = __locals.get("my_graph")
    len(graph["D"]) == 2 and "A" in graph["D"] and "C" in graph["D"]
  `))
})

--seed--

--seed-contents--

--fcc-editable-region--
my_graph = {
    'A': 'B',
    'B': ['A', 'C'],
    'C': 'B'
}
--fcc-editable-region--