Last active
November 9, 2017 16:01
-
-
Save inage/7843395 to your computer and use it in GitHub Desktop.
三角形
This file contains 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
## 三角形 | |
## http://rubyfiddle.com/riddles/6bad3 | |
a = [2, 3, 4, 5, 10] | |
ans = 0 | |
a.combination(3){|v,j,k| | |
if k < (v+j) | |
if ans < (v+j+k) | |
ans = (v+j+k) | |
end | |
end | |
} | |
puts ans |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment