Skip to content

Commit 3dc799d

Browse files
authored
Create triangle.rb
1 parent 017594d commit 3dc799d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

triangle.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def solution(a)
2+
a.sort!
3+
4+
a.each_with_index do |element, index|
5+
next if index > (a.length - 3)
6+
p = a[index]
7+
q = a[index + 1]
8+
r = a[index + 2]
9+
return 1 if ( p+q > r && q+r > p && r+p > q)
10+
end
11+
12+
return 0
13+
end

0 commit comments

Comments
 (0)