Lucky Seven

Published by Mubashir Hassan in

Given an array of numbers, return whether it is possible to make the number 7 by adding any three different numbers together.

Examples

lucky_seven([2, 4, 3, 8, 9, 1]) ➞ true

lucky_seven([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) ➞ true

lucky_seven([0, 0, 0, 2, 3]) ➞ false
# You cannot repeat the same number to make 2 + 2 + 3 = 7

lucky_seven([4, 3]) ➞ false
# You need three different numbers.

Notes

  • Tests will only include numbers.
  • Trivially, any array with a length of less than two automatically fails the test.
Watch a quick demo on how Edabit works.