Last active
November 22, 2018 20:12
-
-
Save mikalai-yankouski/6f184730b9ecc63ddbccac0bd51545fa to your computer and use it in GitHub Desktop.
В одном массиве записано количество мячей, забитых футбольной командой в каждой из 20 игр, в другом - количество пропущенных мячей в этой же игре. Для каждой игры определите словесный результат игры (выигрыш, проигрыш или ничью).
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
def random_numbers(n, range) | |
Array.new(n) { rand(range) } | |
end | |
goals_scored = random_numbers(20, 1..6) | |
goals_missed = random_numbers(20, 1..6) | |
goals_scored.length.times do |i| | |
result = goals_scored[i] - goals_missed[i] | |
if result.positive? | |
puts "Win with the score #{goals_scored[i]}:#{goals_missed[i]}" | |
elsif result.negative? | |
puts "Loss with the score #{goals_scored[i]}:#{goals_missed[i]}" | |
else | |
puts "Tie draw #{goals_scored[i]}:#{goals_missed[i]}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment