#82: My solution passes in my REPL and on the 4clojure Android app, but not on the site

74 views
Skip to first unread message

Jonathan Harford

unread,
Nov 19, 2017, 1:51:33 PM11/19/17
to 4Clojure
The 4clojure app says, "Server rejected our solution! Please submit a bug report."

The site says, "You failed the unit tests".

I'm not so much bothered as I am curious: What's going on?

The code:
(fn __
 
([ins] (__ (apply hash-set (rest ins)) [(first ins)]))
 
([ins chain]
   
(letfn [(neighbors?
             
([word] #(neighbors? word %))
             
([word1 word2]
             
(let [[chr1 & chrs1] word1
                   
[chr2 & chrs2] word2]
               
(if (= chr1 chr2)
                 
(recur chrs1 chrs2)
                 
(or (= chrs1 chrs2)
                     
(= (seq word1) chrs2)
                     
(= chrs1 (seq word2)))))))]
     
(let [next-link (-> chain
                             first
                             neighbors
?
                             
(clojure.set/select ins)
                             first
)
           prev
-link (-> chain
                             
last
                             neighbors
?
                             
(clojure.set/select ins)
                             first
)]
       
(cond
         
(empty? ins)
         
true

         
next-link
         
(recur (disj ins next-link) (concat [next-link] chain ))

         prev
-link
         
(recur (disj ins prev-link) (concat chain [prev-link]))

         
:else
         
false)))))



Reply all
Reply to author
Forward
0 new messages