More Samples
///////////////////////////////////////////////////////////////////////////////
//
// Hundred Fowls Pozzle
//
// In the late fifth and early sixth century, a Chinese mathematician Qiujian
// Zhang (Chang Ch'iu-chien) published a mathematics book, and in Chapter 38 
// he posed a hundred-fowl problem as follows: 
//
// Assume that a cock is worth 5 coins each, a hen 3 coins, and three
// chicks together 1 coin, and that one buys 100 fowls with 100 coins, then how
// many cocks, hens and chicks are there respectively?
//
///////////////////////////////////////////////////////////////////////////////
//
// Using the source code below and running the query 
//
//      all Hundred_Fowls(cocks,hens,chickens)
//
// will generate all four solutions:
//
//  cocks = 0
//  hens = 25
//  chickens = 75
//  ___ Solution: 1 __________________________________
//  
//  cocks = 4
//  hens = 18
//  chickens = 78
//  ___ Solution: 2 __________________________________
//  
//  cocks = 8
//  hens = 11
//  chickens = 81
//  ___ Solution: 3 __________________________________
//  
//  cocks = 12
//  hens = 4
//  chickens = 84
//  ___ Solution: 4 __________________________________
//                                                        
///////////////////////////////////////////////////////////////////////////////

pred Hundred_Fowls(cocks::L[0..],hens::L[0..],chicks::L[0..]) iff
    cocks + hens + chicks = 100 &
    5*cocks + 3*hens + chicks/3 = 100 & chicks mod 3 = 0





This page was created by F1toHTML