Created
May 4, 2022 02:17
-
-
Save scolton99/7b5f07323cff47f7f0efa0fd1b82196c to your computer and use it in GitHub Desktop.
coins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(define coins | |
(list (cons 25 'quarter) | |
(cons 10 'dime) | |
(cons 5 'nickel) | |
(cons 1 'penny))) | |
(define (make-change cents) | |
(if (= cents 0) | |
'() | |
(let ([coin (findf (λ (coin-pair) (<= (car coin-pair) cents)) coins)]) | |
(cons (cdr coin) (make-change(- cents (car coin))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment