\"You're given a hundred dollars and told to spend it all purchasing exactly a hundred animals at the pet store. Dogs cost $15. Cats cost a buck, and mice are 25 cents each.\"
Code: Select all
for dogs in [dogs*15 for dogs in range(100)]:
for cats in [cats*1 for cats in range(100)]:
for mice in [mice*0.25 for mice in range(100)]:
if mice+dogs+cats==100 and (mice/0.25)+(cats/1)+(dogs/15)==100 and mice>0 and cats>0 and dogs>0:
print \"%s Dogs =$%s\"% (dogs/15,dogs)
print \"%s Cats =$%s\"% (cats/1,cats)
print \"%s Mice =$%s\"% (mice/0.25,mice)
My answer:
3 Dogs =$45
41 Cats =$41
56.0 Mice =$14.0