Skip to content

Instantly share code, notes, and snippets.

@barnes7td
Last active March 12, 2019 01:34
Show Gist options
  • Save barnes7td/94953b9c2415ae909ec2 to your computer and use it in GitHub Desktop.
Save barnes7td/94953b9c2415ae909ec2 to your computer and use it in GitHub Desktop.
Job Prep Same Number
# Create a method same_number? that takes a string of x's and o's and determines
# if there are the same number of x's as o's. "xooxxxxooxo" has more x's and
# therefore would return false. "xxooxxooxoxo" has the same amount of x's and o's,
# therefore would return true.
def same_number?(str)
end
same_number?("xooxxxxooxo")
#=> false
same_number?("xxooxxooxoxo")
#=> true
same_number?("xooxxxxooxooo")
#=> false
same_number?("xxooxxooxoxooxoxooxx")
#=> true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment