// Abstract ------------------------------------------------------------------------------------------------------------------------------

A chicken farmer have some chicken and also has some cows for a total of 30 animals, and the animals have 74 legs in all. How many chickens does the farmer have?

// Examples ------------------------------------------------------------------------------------------------------------------------------

?- #solve(:chicken,:cows)
-> ( 23 , 7 ) := 1.00 (0.030) 1
 
// Code ----------------------------------------------------------------------------------------------------------------------------------

solve {

    (:chicken,:cows) :- rng.span(<1|29>,1,:chicken),
                        add(:chicken,:cows,30),
                        mul(:chicken,2,:chicken2),
                        mul(:cows,4,:cows2),
                        add(:chicken2,:cows2,74);

}

// ---------------------------------------------------------------------------------------------------------------------------------------

[Home] [Email] [Twitter] [LinkedIn]