Solve Barn Animal Counts from Total Legs
SIG (Susquehanna)Data Scientist · Online AssessmentLast updated
Tests setting up and solving a system of linear equations from verbal constraints using substitution to determine integer entity counts.
Problem Statement
You are inspecting a barn containing three types of creatures: chickens, ants, and cows.
You observe the following conditions:
- The total number of legs among all creatures in the barn is 570.
- The number of ants is twice the number of chickens.
- The number of cows is twice the number of ants.
Assume standard biological leg counts for all creatures:
- Chickens have 2 legs.
- Cows have 4 legs.
- Ants have 6 legs.
Questions
- Express the number of chickens and cows in terms of the number of ants
A. - Formulate the total leg equation and solve for the exact number of ants
A. - Provide the full counts for chickens, ants, and cows, and verify that the total leg count equals 570.
- Explain why this solution is unique.
Hints
Hint 1
Recall standard biological anatomy: chickens have 2 legs, cows have 4 legs, and ants have 6 legs.
Hint 2
Express all creature counts in terms of a single variable, `A` (ants): `Chickens = A / 2` and `Cows = 2 * A`.
Hint 3
Multiply each creature expression by its respective leg count, sum them to equal 570, and solve for `A`.
Follow-up questions
- If the total leg count were 575 instead, could an exact valid integer count exist under the same animal ratios? Why or why not?
- How would you generalize this algorithm to handle `k` species with given leg counts and a system of linear ratio dependencies?
- What would happen if spiders (8 legs) were introduced such that the number of spiders equaled the number of chickens?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.