Skip to content

Instantly share code, notes, and snippets.

@akreer135
Created November 18, 2013 17:58
Show Gist options
  • Save akreer135/7532320 to your computer and use it in GitHub Desktop.
Save akreer135/7532320 to your computer and use it in GitHub Desktop.
heads, legs = map(float, raw_input().split())
chickens = legs/2
cows = 0
while heads < cows + chickens:
chickens -= 2
cows += 1
if cows*4 + chickens*2 == legs and cows + chickens == heads:
print "There are %d chickens and %d cows." % (chickens, cows)
else:
print "No Solution"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment