Skip to content

Instantly share code, notes, and snippets.

@zevaverbach
Created December 23, 2014 06:21
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 zevaverbach/861aa14e438b2179937d to your computer and use it in GitHub Desktop.
Save zevaverbach/861aa14e438b2179937d to your computer and use it in GitHub Desktop.
Cats in Hats True/False approach
theCats = {}
for i in range(1,101):
theCats[i] = False
for i in range(1,101):
for cats, hats in theCats.iteritems():
if cats % i == 0:
if theCats[cats] == True:
theCats[cats] = False
else:
theCats[cats] = True
for cats, hats in theCats.iteritems():
if theCats[cats] == True:
print "Cat {} has a hat.".format(cats)
else:
print "Cat {} is hatless!".format(cats)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment