Without the constraint that we need 100 pets, if we wanted to minimize the number of pets bought, and because the cost of dogs, cats, and mice divide evenly into each other, we can use an efficient greedy algorithm to exactly solve this problem:

**Code:**

remaining = 10000

dogs, remaining = remaining // 1500, remaining % 1500

cats, remaining = remaining // 100, remaining % 100

mice, remaining = remaining // 25, remaining % 25

print '%d dogs, %d cats, %d mice' % (dogs, cats, mice)

Otherwise, my preference is to just write it as one big list comprehension:

**Code:**

solutions = [(x, y, 100 - x - y)

for x in range(100)

for y in range(100 - x)

if 1500 * x + 100 * y + 25 * (100 - x - y) == 10000]

print '%d dogs, %d cats, %d mice' % solutions[0]

Also, I strictly used integers, since using equality comparison with floating point numbers is bad. For example:

**Code:**

>>> sum([0.2] * 5) == 1.0

True

>>> sum([0.1] * 10) == 1.0

False

Essentially, you can't guarantee that they will always round exactly the way you want them to, so they could be off by an extremely small fraction and thus not be equal.