#120 times out

88 views
Skip to first unread message

Jannik Jochem

unread,
Jul 10, 2012, 10:56:52 AM7/10/12
to 4clo...@googlegroups.com
Hello,

I've been trying to solve Problem 120. In a REPL, the following solution works:

(fn [xs]
  (count
    (filter
      (fn [x]
        (< x
          (reduce + (map
            (comp #(* % %) #(Integer/parseInt (str %)))
          (seq (str x))))))
      xs)))


When I try to submit this solution, I always hit a timeout. Is it possible that the last test case is a little over the top?

Cheers,

Jannik

hak

unread,
Jul 10, 2012, 2:23:40 PM7/10/12
to 4clo...@googlegroups.com

i checked my old solution for the problem, it is about as fast as yours and did not timeout. So there seems to be a problem with 4clojure.

Cheers,
    hak 
 

ctzsm

unread,
Sep 27, 2012, 12:07:46 AM9/27/12
to 4clo...@googlegroups.com
It seems that the Integer/parseInt is very slow in the sandbox of 4clojure.

so you can replace it with something else.

I tried your solution and replaced the Integer/parseInt, it works fine.
Reply all
Reply to author
Forward
0 new messages