Atlassian SDE-2 Karat Round
Question 1
Input Structure:
We have two inputs: a list of available parts and a list of required parts for each robot.
Each robot's required parts are stored in a dictionary where the key is the robot name and the value is a list of parts needed.
Output:
We need to return a list of robot names that can be fully constructed with the available parts.
List = [
"Rosie_claw",
"Rosie_sensors",
"Dustie_case",
"Optimus_sensors",
"Rust_sensors",
"Rosie_case",
"Rust_case",
"Optimus_speaker",
"Rosie_wheels",
"Dustie_case",
"Dustie_arms",
"Rust_claw",
"Dustie_case",
"Dustie_speaker",
"Optimus_case",
"Optimus_wheels",
"Optimus_wheels",
"Rust_legs",
"Optimus_sensors"
]
Available Parts = {"sensors", "case", "speaker", "wheels"}
output - [Optimus, Rosie]
Question 2
You work in an automated robot factory. Once robots are assembled, they are sent to the shipping center via a series of autonomous delivery carts, each of which moves packages on a one-way route.
Given input that provides the (directed) steps that each cart takes as pairs, write a function that identifies all the start locations, and a collection of all of the possible ending locations for each start location.
In this diagram, starting locations are at the top and destinations are at the bottom - i.e. the graph is directed exclusively downward.
1
2 A E J Key: [Origins]
3 / \ / \ \ \
4 B C F L M [Destinations]
5 \ / \ /
6 K G
7 / \
8 H Ipaths = [
["B", "K"],
["C", "K"],
["E", "L"],
["F", "G"],
["J", "M"],
["E", "F"],
["C", "G"],
["A", "B"],
["A", "C"],
["G", "H"],
["G", "I"]
]
Expected output (unordered):
[
"A": ["K", "H", "I"],
"E": ["H", "L", "I"],
"J": ["M"]
]
N: Number of pairs in the input.