Make Binary Digits' solution more functional.