simple-exercises/ruby-exercises/easy-6.rb
# Write a function lucky_sevens?(numbers), which takes in an array of integers
# and returns true if any three consecutive elements sum to 7
Write a function lucky_sevens?(numbers), which takes in an array of integers
and returns true if any three consecutive elements sum to 7
Write a function lucky_sevens? ( numbers ) which takes in an array of integers and returns true if any three consecutive elements sum to 7
def lucky_sevens?(nums)
  if nums.length < 3
    return false
  end
  n = nums.length - 3
  (0..n).each do |i|
    if nums[i...(i+3)].sum == 7
      return true
    end
  end
  false
end
def lucky_sevens? ( nums ) if nums . length < 3 return false end n = nums . length - 3 ( 0 .. n ) . each do | i | if nums [ i ... ( i + 3 ) ] . sum == 7 return true end end false end
Write a function lucky_sevens?
Write a function lucky_sevens?
# .. is inclusive
nums
<not_specific>