Make 100 Doors problem's solution more functional.