Problem_Set_01_Solutions_Code

Problem_Set_01_Solutions_Code - ; Discrete Math PS-1 ;...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
;;; Discrete Math PS-1 ;;; Shyam Visweswaran ;;; Exercise 3 ;;; ADU-ball - To express any number >= 60 as a combination ;;; of 11s and 7s. (define (adu-ball n) (define (helper elevens sevens) (let ((total (+ (* 11 elevens) (* 7 sevens)))) (cond ((< n 60) '(Error: Enter a number greater than 59)) ((= total n) (list 'goals: elevens 'misses: sevens)) ((> total n) (helper 0 (+ 1 sevens))) (else (helper (+ 1 elevens) sevens))))) (helper 0 0)) ;; Lets test now (adu-ball 59) ;Value: (error: enter a number greater than 59) (adu-ball 60) ;Value: (goals: 1 misses: 7) (adu-ball 61) ;Value: (goals: 3 misses: 4) (adu-ball 62) ;Value: (goals: 5 misses: 1) (adu-ball 63) ;Value: (goals: 0 misses: 9) (adu-ball 64) ;Value: (goals: 2 misses: 6) (adu-ball 65) ;Value: (goals: 4 misses: 3) (adu-ball 66) ;Value: (goals: 6 misses: 0) (adu-ball 67) ;Value: (goals: 1 misses: 8) (adu-ball 68) ;Value: (goals: 3 misses: 5) (adu-ball 69) ;Value: (goals: 5 misses: 2) (adu-ball 70) ;Value: (goals: 0 misses: 10)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 10/01/2011.

Page1 / 3

Problem_Set_01_Solutions_Code - ; Discrete Math PS-1 ;...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online