Skip to content

Instantly share code, notes, and snippets.

@havenwood
Last active March 31, 2020 20:06
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 havenwood/de17d285e53fc88ec0328d3a588d7606 to your computer and use it in GitHub Desktop.
Save havenwood/de17d285e53fc88ec0328d3a588d7606 to your computer and use it in GitHub Desktop.
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]
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