Created
January 26, 2021 01:06
-
-
Save justinmeiners/d5aadebbd9fc46ed6beac6f7bbd5e818 to your computer and use it in GitHub Desktop.
This file contains 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
; https://en.wikiversity.org/wiki/Binomial_coefficients | |
(defun arrangements (n k) | |
(if (= n 0) | |
(list nil) | |
(append | |
(when (< k n) | |
(mapcar (lambda (tail) | |
(cons 0 tail)) | |
(arrangements (- n 1) k))) | |
(when (> k 0) | |
(mapcar (lambda (tail) | |
(cons 1 tail)) | |
(arrangements (- n 1) (- k 1)) | |
))))) | |
(arrangements 4 3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment