Generate outputs for images and pipelines
AnthropicSoftware Engineer · Technical ScreenLast updated
This question evaluates algorithmic and systems engineering skills related to batch image processing, parallelization, I/O versus CPU trade-offs, and deterministic output association within the Coding & Algorithms domain.
You are given m input images and n processing pipelines.
- Each pipeline is an ordered list of k operations (e.g., resize, rotate, crop, blur, color transform).
- Applying a pipeline to an image produces a new output image.
Task
Write a function/program that produces m × n output images by applying every pipeline to every input image.
Requirements
- Each output should be associated with
(image_id, pipeline_id). - The pipeline operations must be applied in order.
- Assume images are stored as file paths; pipelines are provided as callable operations.
- Your implementation should be structured so it can be parallelized easily (e.g., avoid unnecessary repeated work such as reading the same image multiple times).
Input/Output (one reasonable interface)
- Input:
image_paths: List[str](size m)pipelines: List[List[Callable[[Image], Image]]](size n, each of length k)output_dir: str- Output:
- Write
m*nimages tooutput_dirwith deterministic names likeimg{idx}_pipe{j}.png, or return a list of output file paths.
Constraints (assume)
m, ncan be large enough that runtime and I/O efficiency matter.- Operations may be CPU-bound; image decoding/encoding is I/O-bound.
Follow-up discussion (no need to implement)
- How would you scale this for large
mandn? - What parallelization strategy would you choose and why?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.