Incorrect solution for #81

75 views
Skip to first unread message

katox

unread,
Jul 20, 2012, 7:43:47 PM7/20/12
to 4clo...@googlegroups.com
Hi, I'm probably nitpicking but I don't think an accepted solution for #81 set intersection should include things like

#(set (filter % %2))
;; and
#(set (keep % %2))

because of false values not being included, as

(#(set (filter % %2)) #{0 1 false 2 nil 3} #{2 3 4 false nil 5})
;;=> #{2 3}
(#(set (keep % %2)) #{0 1 false nil 2 3} #{2 3 4 nil false 5})
;;=> #{2 3 false}
;;
;; should be #{2 3 false nil}

rewording the task would help too of course ;)

Cheers,
Kamil Toman

P.S. I love 4clojure, thanks!

Leif

unread,
Jul 21, 2012, 8:07:39 AM7/21/12
to 4clo...@googlegroups.com
I agree, and it points to a pet peeve of mine about 4clojure: the "code golf" and regular solutions are not differentiated.  The bug you mention is shared by lots of solutions by extremely good clojure programmers; I think they purposefully wrote buggy, yet passing, solutions for the sake of brevity and code golf scores.  I find this to be a real problem when looking at other people's solutions for advanced problems: you can tell who's playing code golf, because their code is almost unreadable.

This is fine for "4clojure the fun game," but bad for "4clojure the educational resource."  Maybe leagues should have separate submissions?  Or even let you snapshot at any time?  I for one would like to see if people started out with straightforward solutions and slowly refactored them into the dense, elegant solutions that baffle me.

Leif

katox

unread,
Jul 22, 2012, 6:28:13 PM7/22/12
to 4clo...@googlegroups.com
Yes. It's clearly on purpose. However people coming to learn clojure won't probably spot all cut corners and it might bite them later.

Splitting "code golf" (~ the smallest code passing given tests) and clean (complete solutions that solve the problem sounds like a good idea.
A nice side-effect is that beefing up tests to reject solutions with obviously cut corners would help beginners to learn about hairy corner cases in their own solutions.

K.
Reply all
Reply to author
Forward
0 new messages