Skip to content

Instantly share code, notes, and snippets.

@sandeep1988
Created February 20, 2020 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sandeep1988/081fea0e768e6335abc8882d4af3d224 to your computer and use it in GitHub Desktop.
Save sandeep1988/081fea0e768e6335abc8882d4af3d224 to your computer and use it in GitHub Desktop.
assignment3
a = [
["B", "C", "Win"], ## b= 3
["A", "B", "Win"], # a = 3
["D", "C", "Loss"], # c = 3
["C", "A", "Loss"], # a = 6
["B", "D", "Win"], # b = 6
["A", "D", "Draw"], ## a 7 , d = 1
["A", "B", "Draw"], # a = 8, b = 7, c = 3 , d = 1
]
@ta = 0
@tb = 0
@tc = 0
@td = 0
# @res = []
a.each do |i|
if i[2] == 'Win'
if i[0] == "A"
@ta += 3
elsif
i[0] == "B"
@tb += 3
elsif
i[0] == "C"
@tc += 3
elsif
i[0] == "D"
@td += 3
end
elsif i[2] == 'Loss'
if i[1] == "A"
@ta += 3
elsif
i[1] == "B"
@tb += 3
elsif
i[1] == "C"
@tc += 3
elsif
i[1] == "D"
@td += 3
end
elsif i[2] == 'Draw'
if i[0] == "D" || i[1] == "D"
@td += 1
end
if i[0] == "B" || i[1] == "B"
@tb += 1
end
if i[0] == "C" || i[1] == "C"
@tc += 1
end
if i[0] == "A" || i[1] == "A"
@ta += 1
end
end
end
p "Team A - Score #{@ta}"
p "Team B - Score #{@tb}"
p "Team C - Score #{@tc}"
p "Team D - Score #{@td}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment