GitHub Interview Question

Solve this Ruby coding problem