Skip to content

Instantly share code, notes, and snippets.

@scolton99
Created May 4, 2022 02:17
Show Gist options
  • Save scolton99/7b5f07323cff47f7f0efa0fd1b82196c to your computer and use it in GitHub Desktop.
Save scolton99/7b5f07323cff47f7f0efa0fd1b82196c to your computer and use it in GitHub Desktop.
coins
#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