```
weights.size.times do |index|
  if weights.take(index + 1).sum > trigger
    result = weights[index]
    break
  end
end
```