Skip to content

Instantly share code, notes, and snippets.

@ayato-p
Created August 18, 2013 04:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayato-p/6259886 to your computer and use it in GitHub Desktop.
Save ayato-p/6259886 to your computer and use it in GitHub Desktop.
(let loop ((p 10) (n 4))
(cond [(= n 0) 0]
[(= n 1) p]
[else
(let in-loop ((c 1) (ans '()))
(cond [(<= p 1) c]
[(> c (- p n)) ans]
[else (in-loop (+ c 1)
(cons
`(,c ,@(loop (- p c) (- n 1)))
ans))]))]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment