GitHub interview question

Solve this Ruby coding problem