Build a solver for the cow and chicken problem
Mathematica 359 314
About 200 characters went into determining which condition applies.
f@{a_, b_, c_, d_, i_, l_} :=
 Module[{s, t, z = &quot;invalid problem&quot;, y = IntegerQ},
  t@n_ := y@n \[And] (n &gt; 0);
  p@n_ := n \[Element] Rationals \[And] n &gt; 0;
  q@n_ := n \[Element] Reals;
  w = Flatten@Quiet@Solve[{d*x + b*k == l, c*x + a*k == i}, {k, x}];
  s = {k, x} /. w;
  Which[w == {}, {5, z},
   Length[w] != 2, {6, z},
   True, If[And @@ (t /@ s), {1, s},
    Which[
     And @@ (p /@ s), {2, z},
     And @@ (y /@ s), {3, z},
     And @@ (q /@ s), {4, z},
     3 == 3, {7, z}]]]]


f[{1, 4, 1, 2, 24, 68}]
f[{7, 14, 9, 6, 25, 18}]
f[{1, 4, 1, 2, 24, 67}]
f[{1, 4, 1, 2, 24, 36}]
f[{1, 4, 1, 2, 24, 97}]
f[{2, 4, 1, 2, 24, 68}]
f[{2, 4, 1, 2, 24, 48}]
f[{1, 4, 1, 2, -23, (3 + I)^2/(5 - I)}]
f[{6, 9, 4, 6, 10, 15}]


{1, {10, 14}}
{2, &quot;invalid problem&quot;}
{2, &quot;invalid problem&quot;}
{3, &quot;invalid problem&quot;}
{4, &quot;invalid problem&quot;}
{5, &quot;invalid problem&quot;}
{6, &quot;invalid problem&quot;}
{7, &quot;invalid problem&quot;}
{6, &quot;invalid problem&quot;}  

How it works
The  equations d*x+b*k==land c*x+a*k==i express the constraints in the general cow and chickens problem,where

a is &quot;the number of heads per cow&quot;
b is &quot;the number of legs per cow&quot;
c is &quot;the number of heads per chicken&quot;
d is &quot;the number of legs per chicken&quot;
i is &quot;the number of  heads&quot;
l is &quot;the number of legs&quot;
k is &quot;the number of cows&quot;
x is &quot;the number of chickens&quot;.

Solve returns the real - valued solutions, if any exist, for the cows and chickens, as a list of 2 substitution rules, e.g.
{k-&gt;10, x-&gt; 14}
If no solutions exist, an empty list is returned.
If the data cannot be processed, Solve will return a different number of elements.
The tests are performed in the following order.

If there are 0 solutions, condition 5 is satisfied

If the list of &quot;solution&quot;s has anything other than 2 elements, then condition 6 is satisfied .

If there are 2 solutions, then

if function t yields True, the solution is a pair of non-negative integers, and condition 1 is satisfied.
if function p yields True, the solution is a pair of  non negative rationals and condition 2 is satisfied.
if function q yields True, the solution is a pair of  non negative rationals and condition 3 is satisfied.
if function y yields True, the solution is a pair of  integers and condition 4 is satisfied.
Otherwise, condition 7 is satisfied.



Minor Variant of f
g@{a_, b_, c_, d_, i_, l_} := 
 Module[{s, t, z = &quot;invalid problem&quot;, y = IntegerQ}, 
  t@n_ := y@n \[And] (n &gt; 0);
  p@n_ := n \[Element] Rationals \[And] n &gt; 0;
  q@n_ := n \[Element] Reals;
  w = Flatten@Quiet@Solve[{d*x + b*k == l, c*x + a*k == i}, {k, x}];
  s = {k, x} /. w;
  Which[w == {}, {5, z, w}, Length[w] != 2, {6, z, w}, True, 
   If[And @@ (t /@ s), {1, s, w}, 
    Which[And @@ (p /@ s), {2, z, w}, And @@ (y /@ s), {3, z, w}, 
     And @@ (q /@ s), {4, z, w}, 3 == 3, {7, z, w}]]]]

g is f` with the additional property that it returns the output of Solve.
g[{1, 4, 1, 2, 24, 68}]
g[{7, 14, 9, 6, 25, 18}]
g[{1, 4, 1, 2, 24, 67}]
g[{1, 4, 1, 2, 24, 36}]
g[{1, 4, 1, 2, 24, 97}]
g[{2, 4, 1, 2, 24, 68}]
g[{2, 4, 1, 2, 24, 48}]
g[{1, 4, 1, 2, -23, (3 + I)^2/(5 - I)}]
g[{6, 9, 4, 6, 10, 15}]


{1, {10, 14}, {k -&gt; 10, x -&gt; 14}}
{2, &quot;invalid problem&quot;, {k -&gt; 1/7, x -&gt; 8/3}}
{2, &quot;invalid problem&quot;, {k -&gt; 19/2, x -&gt; 29/2}}
{3, &quot;invalid problem&quot;, {k -&gt; -6, x -&gt; 30}}
{4, &quot;invalid problem&quot;, {k -&gt; 49/2, x -&gt; -(1/2)}}
{5, &quot;invalid problem&quot;, {}}
{6, &quot;invalid problem&quot;, {x -&gt; 24 - 2 k}}
{7, &quot;invalid problem&quot;, {k -&gt; 615/26 + (19 I)/26, x -&gt; -(1213/26) - (19 I)/26}}
{6, &quot;invalid problem&quot;, {x -&gt; 5/2 - (3 k)/2}}

Problems falling under condition 6 have multiple solutions, as evidence by the equations.  The problem that falls under condition 5 returns an empty set (no solutions).
Note: element and and are single characters in Mathematica.