Created
January 14, 2016 04:06
-
-
Save rewinfrey/44628d0fb4f8a5045e91 to your computer and use it in GitHub Desktop.
something for verifying / calculating powerball numbers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@actual_numbers = [4, 8, 19, 27, 34, 10] | |
def powerball_match?(numbers) | |
@actual_numbers.last == numbers.last | |
end | |
def white_ball_matches?(numbers, minimum_match_count) | |
numbers.select { |number| @actual_numbers[0..-2].include? number }.count >= minimum_match_count | |
end | |
def powerball_plus_whites?(numbers, minimum_match_count) | |
@actual_numbers.last == numbers.last && white_ball_matches?(numbers, minimum_match_count) | |
end | |
def generate_quick_picks(num) | |
white_balls = [*1..69] | |
power_balls = [*1..26] | |
num.times do | |
puts "#{white_balls.sample} #{white_balls.sample} #{white_balls.sample} #{white_balls.sample} #{white_balls.sample} #{power_balls.sample}" | |
end | |
end | |
numbers_collection = [[]] | |
result = numbers_collection.reduce("") do |outcome, numbers| | |
outcome << "JACKPOT: #{numbers}\n" if powerball_plus_whites?(numbers, 5) | |
outcome << " $1,000,000: #{numbers}\n" if white_ball_matches?(numbers, 5) | |
outcome << " $50,000: #{numbers}\n" if powerball_plus_whites?(numbers, 4) | |
outcome << " $100: #{numbers}\n" if white_ball_matches?(numbers, 4) || powerball_plus_whites?(numbers, 3) | |
outcome << " $7: #{numbers}\n" if powerball_plus_whites?(numbers, 2) || white_ball_matches?(numbers, 3) | |
outcome << " $4: #{numbers}\n" if powerball_match?(numbers) || powerball_plus_whites?(numbers, 1) | |
outcome | |
end | |
puts result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment