Created
January 3, 2020 17:50
-
-
Save venelrene/8e633d0f41b5d88522fe97cfe2c8064f to your computer and use it in GitHub Desktop.
For inputArray = [5, 1, 2, 3, 0, 1, 5, 0, 2], the output should be 11. The answer was obtained as 5 + 1 + 2 + 3 = 11.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def house_numbers_sum(input_array) | |
| input_array.take_while { |n| n > 0 }.sum | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment