Arc Forumnew | comments | leaders | submitlogin
1 point by jmatt 6035 days ago | link | parent

http://codegolf.com/choose

  (def f (n) (if (> n 0) (* n (f (- n 1))) 1))(def c (n k) (/ (f n) (f k) (f (- n k))))(def m (i) (let v (map [coerce (trim _ 'both) 'int] (tokens i #\,)) (c (car v) (cadr v))))
or

  (def f (n) 
    (if (> n 0) 
      (* n (f (- n 1))) 1))
  (def c (n k)
    (/ (f n) (f k) (f (- n k))))
  (def m (i) 
    (let v
      (map [coerce (trim _ 'both) 'int] (tokens i #\,)) 
      (c (car v) (cadr v))))
(m "5, 3")

(m "22, 9")

(m "100, 3")

(m "75, 71")

(m "30, 1")

(m "1, 1")

(m "4, 0")

v 1.0 of code golf choose challenge. 175 bytes passes test cases minimal work to simplify or shorten it.