Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save willshepp28/0fec25a4fb9cbd77cc0c2d1226c30bc9 to your computer and use it in GitHub Desktop.
Save willshepp28/0fec25a4fb9cbd77cc0c2d1226c30bc9 to your computer and use it in GitHub Desktop.
# @param {Integer[]} candies
# @param {Integer} extra_candies
# @return {Boolean[]}
def kids_with_candies(candies, extra_candies)
greatest_value = 0
#loop through the array and store the value with the greatest value
candies.each do |candy|
greatest_value = candy if candy > greatest_value
end
#loop back through and compare each value against the greatest value
return candies.map { |candy|
(candy += extra_candies) >= greatest_value ? true : false
}
#return the results
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment