Start of topic | Skip to actions

Solution: fastest-runner

; fastest-runner: nonnegative-number -> symbol
;
; Purpose: Given a distance to run (in meters),
; return the fastest runner on the team.
;
(define (fastest-runner distance)
  (cond [(< distance  300)                            'Marianne]
        [(and (>= distance  300) (< distance  1000))  'Becca]
        [(and (>= distance 1000) (< distance 10000))  'Suzy]
        [(>= distance 10000)                          'Yvonne]))

'fastest-runner_examples
(symbol=? (fastest-runner 10000) 'Yvonne)
(symbol=? (fastest-runner  8000) 'Suzy)
(symbol=? (fastest-runner  2000) 'Suzy)
(symbol=? (fastest-runner   200) 'Marianne)
(symbol=? (fastest-runner   999) 'Becca)

Access Permissions


End of topic
Skip to actions | Back to top
Creative Commons LicenseThis work is licensed under a Creative Commons Attribution 2.5 License. Please follow our citation guidelines.