I'm just getting started on the site CodeEval, and I submitted my first solution today. What I don't understand is why it's marking my (working) answer as only a "partial solution". The site doesn't seem to want to explain why my answer is only "partial", and I'm hoping someone here can explain why.

The challenge I was trying to do was FizzBuzz, where you take in three numbers as input and output a sequence of increasing numbers, substituting "F" for a number if it's divisible by the first input number, "B" for a number if it's divisible by the second input number, and "FB" if it's divisible by both.

Here's my solution:

(defn process-line [[x y n]]
  (for [i (range 1 (inc n))]

  (and (zero? (mod i x)) (zero? (mod i y))) "FB"
  (zero? (mod i x)) "F"
  (zero? (mod i y)) "B"

  :else (str i))))

(defn string->int [string]
  (let [elements (clojure.string/split string #" ")]
    (into [] (map read-string elements))))

; Sample code to read in test cases:
; Open the file passed as the first command line argument
(with-open [rdr (clojure.java.io/reader (first *command-line-args*))]
  ; Read each line ignoring empty ones
  (doseq [line (remove empty? (line-seq rdr))]
    (let [out-line (process-line (string->int  line))]
    (println (clojure.string/join " " out-line)))))

The only thing I can think of is the following: when it shows the memory usage of my working solution (it currently uses 71098368 bytes) there's a little tooltip that says "Reduce memory usage to 20Mb". Is that the cause of the "partial" in my solution, and, if so, how could I reduce my memory usage? My solution already seems pretty simple.

  • \$\begingroup\$ Hi! Welcome to Code Review. This question seems on-the-line right now, it asks "Why is this not quite working?" but might be possibly the result of over-memory usage, which isn't really "not working" but more "not working fast enough". \$\endgroup\$ Oct 24, 2015 at 22:10
  • \$\begingroup\$ It seems that it is memory usage: When I submitted it while the memory usage was still processing, the puzzle was solved. However when the memory was calculated, it changed into partially. \$\endgroup\$ Oct 24, 2015 at 22:17
  • \$\begingroup\$ Thanks for the reply. Do you have any suggestions on how I can improve memory usage? I haven't had to optimize something that much before. \$\endgroup\$
    – RGrun
    Oct 24, 2015 at 22:32
  • 1
    \$\begingroup\$ I had the same memory consumption issue when submitting CORRECT solutions written in Clojure on CodeEval. Turns out CodeEval.com doesn't work with Clojure. I switched to submitting solutions in Haskell which works just fine. \$\endgroup\$
    – birq
    Feb 6, 2016 at 21:46
  • 1
    \$\begingroup\$ Under the assumption that the above is the problem with the challenge result... would you still want a review? \$\endgroup\$
    – Vogel612
    Feb 6, 2016 at 22:06


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.