I think Win Carus wrote: > (defrule find-solution > (coin (denomination penny) (count ?cp) (amount ?ap)) > (test (= 0 (mod ?cp 5))) > (coin (denomination nickel) (count ?cn) (amount ?an)) > (test (< (+ ?ap ?an) ?*totalAmt*)) > (coin (denomination dime) (count ?cd) (amount ?ad)) > (test (< (+ ?ap ?an ?ad) ?*totalAmt*)) > (coin (denomination quarter) (count ?cq) (amount ?aq)) > (test (< (+ ?ap ?an ?ad ?aq) ?*totalAmt*)) > (coin (denomination half-dollar) (count ?ch) (amount ?ah)) > (test (= (+ ?ch ?cq ?cd ?cn ?cp) ?*coinCount*)) > (test (= (+ ?ah ?aq ?ad ?an ?ap) ?*totalAmt*)) > => > (printout t "Solution : " ?cp " pennies, " ?cn " nickels, " ?cd " dimes, > " ?cq " quarters, " ?ch " half-dollars" crlf)) >
Actually I was already doing that -- here's what mine looks like (assumes mod 5 for pennies was done during the setup phase:) (defrule find-solution (coin (denomination half-dollar) (count ?ch) (amount ?ah)) (coin (denomination quarter) (count ?cq&:(<= (+ ?cq ?ch) ?*coinCount*)) (amount ?aq&:(<= (+ ?aq ?ah) ?*totalAmt*))) (coin (denomination dime) (count ?cd&:(<= (+ ?cd ?cq ?ch) ?*coinCount*)) (amount ?ad&:(<= (+ ?ad ?aq ?ah) ?*totalAmt*))) (coin (denomination nickel) (count ?cn&:(<= (+ ?cn ?cd ?cq ?ch) ?*coinCount*)) (amount ?an&:(<= (+ ?an ?ad ?aq ?ah) ?*totalAmt*))) (coin (denomination penny) (count ?cp&:(= (+ ?cp ?cn ?cd ?cq ?ch) ?*coinCount*)) (amount ?ap&:(= (+ ?ap ?an ?ad ?aq ?ah) ?*totalAmt*))) => (printout t "Solution : " ?cp " pennies, " ?cn " nickels, " ?cd " dimes, " ?cq " quarters, " ?ch " half-dollars" crlf)) 50 coins, $1.00: 0.627 50, $2.00: 0.805 50/$3.00: 1.165 50/$4.00: 1.881 50/$10.00 15.326 --------------------------------------------------------- Ernest Friedman-Hill Distributed Systems Research Phone: (925) 294-2154 Sandia National Labs FAX: (925) 294-2234 PO Box 969, MS 9012 [EMAIL PROTECTED] Livermore, CA 94550 http://herzberg.ca.sandia.gov -------------------------------------------------------------------- To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED] --------------------------------------------------------------------