Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Create a module `CustomEnumerable` that implements `map`, `select`, and `reduce` methods without using built-in Enumerable.

Hard

Problem Statement

Create a module CustomEnumerable that implements map, select, and reduce methods without using built-in Enumerable.

Sample Input

arr = [1, 2, 3]; arr.custom_map { |x| x * 2 }

Sample Output

[2, 4, 6]

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
module CustomEnumerable def custom_map # Your code here end end
Log in or sign up to run or submit your code.Log inSign up
Input
arr = [1, 2, 3]; arr.custom_map { |x| x * 2 }
Expected Output
[2, 4, 6]