;; contract:
;; owe: nat within-two?: num num --> numboolean
;;
;; purpose:
;; (oweReturns n)true returnsif howtwo muchnumbers moneyare youwithin owe2 forof
;; each other, eatingthat nis, slicesreturns oftrue pizzaif wherem the- pizzan
;;and n - costs $12m
;; and there are 8both slicesless perthan pizza2.
;;
;; Examples:
(check-expect (within-two? 99.8 101) true)
(check-expect (within-two? 101 99.8) true)
(check-expect (owe 4) 6within-two? 5 -5) false)
(check-expect (owe 15) 22.5within-two? -5 5) false)
(check-expect (within-two? 5 3) false)
(check-expect (owe 0) 0within-two? 3 5) false)
(check-expect (owe 8) 12)within-two? 42 42) true)
;;
;; definitionDefinition:
(define (owe slices)
(* slices (/ 12 8within-two? m n)
(and (< (- m n) 2) (< (- n m) 2)))
|