Greedy
152 / 170GreedyLesson 6 of 9About 38 min
A one-line filter that makes the rest of the problem trivial, and the argument for why it is safe.
Combining two tuples takes the larger value in each position. A tuple that already exceeds the target somewhere is combined anyway, to see what happens. Type the three lines it prints.
target = (2, 7, 5)poison = (1, 8, 4)helpful = (2, 5, 3) combined = tuple(max(a, b) for a, b in zip(poison, helpful))print("poison combined with a good one:", combined)print("still within the target?", all(v <= t for v, t in zip(combined, target)))print("can any later combination lower the 8?", False)Read the constraints first and let them tell you what complexity is expected. Derive the approach, implement it, run the tests, and submit when it passes.