Instead of trial and error, you could use algebra.

Horses and chickens, 48 heads, 182 legs

H + C = 48 (total animals is 48)

and

4H + 2C = 182 (equations from the definition of the problem)

C=48-H (basic algebra)

Therefore, plugging C back into the second equation gives:

4H + 96 -2H = 192

Subtract 96 from each side:

2H = 86

Divide both by 2:

H = 43

and so C has to equal 5.

5 Chickens, 43 Horses, and a simple application of algebra and the method of solving for 2 variables with 2 equations.

Q.E.D.