Legs on a Farm
After a long and fulfilling career, Chef has decided to retire to a farm out in the countryside. This farm has several cows and chickens, but Chef doesn't know exactly how many of each there are — he can only see that there are $N$ legs in total across all the animals. Note that each cow has $4$ legs and each chicken has $2$ legs, and it is guaranteed that $N$ is even. With $N$ legs in total,
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start