The Map Reducer
A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- medium
- Seniority
- L3
Problem
Given a list of values, a mapper (single-arg function or lambda source string), and a reducer (two-arg function or lambda source string), apply mapper to each value, then reduce left-to-right with reducer. Return the final reduced value, or None if values is empty. If mapper or reducer is a string, eval it into a callable first.
Summary
Map it. Reduce it. One answer.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.