-
-
Save havenwood/de17d285e53fc88ec0328d3a588d7606 to your computer and use it in GitHub Desktop.
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 compare_triplets(a, b) | |
a.zip(b).map { |left, right| left <=> right }.then do |rounds| | |
[rounds.count(1), rounds.count(-1)] | |
end | |
end | |
compare_triplets([10, 2, 8], [8, 3, 8]) | |
#=> [1, 1] |
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 compare_triplets(a, b) | |
player_a = 0 | |
player_b = 0 | |
a.zip(b) do |left, right| | |
player_a += 1 if left > right | |
player_b += 1 if right > left | |
end | |
[player_a, player_b] | |
end | |
compare_triplets([10, 2, 8], [8, 3, 8]) | |
#=> [1, 1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment