Arc Forumnew | comments | leaders | submitlogin
Great source for simple coding problems. Is arc competitive? (codegolf.com)
2 points by jmatt 5762 days ago | 4 comments


1 point by jmatt 5761 days ago | link

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.

-----

1 point by jmatt 5762 days ago | link

The problems include excellent descriptions and test cases.

Plus as a bonus you can code golf and try for the shortest solution. I haven't code golfed anything in arc, but I bet it'll do well.

-----

1 point by lojic 5762 days ago | link

Hmm... I'd expect a language with lots of syntax and a large built-in library to do well.

-----

1 point by jmatt 5762 days ago | link

That is true for some of the problems but not all of them. For instance the choose challenge.

I also think it's part of PG's design goals to have a concise powerful language. (http://www.paulgraham.com/arcchallenge.html)

Even though code golf is program length instead of counting codetree nodes, it's a similar idea and provides interesting small problems to learn on.

-----