Skip to content

Instantly share code, notes, and snippets.

Created January 25, 2016 00:28
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 anonymous/9be20569fd1913e5a6fc to your computer and use it in GitHub Desktop.
Save anonymous/9be20569fd1913e5a6fc to your computer and use it in GitHub Desktop.
def bulls_cows_match(secret, guess)
sa, ga = *[secret, guess].map(&:chars)
[bulls = ga.zip(sa).select { |f, s| f == s }.size, (ga & sa).size - bulls].zip('AB'.chars).join
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment