-
-
Save giruzou/1b17ff6fb9e2dd5fb01ff26f6771d71b to your computer and use it in GitHub Desktop.
Ruby配列の余りの合計 ref: https://qiita.com/DrqYuto/items/4cef67bca6d8569af101
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 mod_sum(array, n) | |
| return array.length > 0 ? array.map{ |number| number % n }.inject{ |sum, number| sum + number } : 0 | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment