Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def numberOfTriangles2(sticks)
- array_length = sticks.length
- x = 0
- y = x + 1
- z = y + 1
- triangles = 0
- while (x < array_length)
- while (y < array_length)
- while (z < array_length)
- if sticks[x] + sticks[y] > sticks[z] then
- triangles = triangles + 1
- end
- z = z + 1
- end
- y = y + 1
- z = y + 1
- end
- x = x + 1
- y = x + 1
- z = y + 1
- end
- return triangles
- end
Advertisement
Add Comment
Please, Sign In to add comment