• Sign Up
    Time to claim your honor
  • Training
  • Practice
    Complete challenging Kata to earn honor and ranks. Re-train to hone technique
  • Freestyle Sparring
    Take turns remixing and refactoring others code through Kumite
  • Community
  • Leaderboards
    Achieve honor and move up the global leaderboards
  • Chat
    Join our Discord server and chat with your fellow code warriors
  • Discussions
    View our Github Discussions board to discuss general Codewars topics
  • About
  • Docs
    Learn about all of the different aspects of Codewars
  • Blog
    Read the latest news from Codewars and the community
  • Log In
  • Sign Up
gargamel Avatar
Name:Unknown
Clan:Unknown
Member Since:Jul 2019
Last Seen:May 2023
Profiles:
    Following:0
    Followers:2
    Allies:0
    View Profile Badges
    • Stats
    • Kata
    • Collections
    • Kumite
    • Social
    • Discourse
    • Conversations (17)
    • Replies
    • Authored
    • Needs Resolution
    • Custom User Avatar
      • m4dd4dd4m
      • commented on "Which are in?" clojure solution
      • 4 years ago

      It will not work with the data like this

      a1: ["olp" "love" "string" "love"]
      a2: ["ulove" "alove" "holp" "sholp","vfmstring"]
      r: ["love" "olp" "string"]

      Because dedupe - "Returns a lazy sequence removing consecutive duplicates in coll."

    • Custom User Avatar
      • gargamel
      • commented on ""get character from ASCII Value" Clojure Translation"
      • 6 years ago

      Do you mean that I should put the "doseq" in the "deftest"?

    • Custom User Avatar
      • Unnamed
      • commented on ""get character from ASCII Value" Clojure Translation"
      • 6 years ago

      There should be more than 1 test. deftest creates a top level definition.

    • Custom User Avatar
      • gargamel
      • commented on ""Path Finder #1: can you reach the exit?" Clojure Translation"
      • 6 years ago

      There are randomized tests that are pregenerated, as described in the comment:
      ; these are were generated offline as random string creation is very time consuming in clojure
      ; they are based on C++'s algorithm as follows:
      ; first and last cells are always clear, maze size between 4 and 11 (not including line breaks), 1 out of 3 chance for a wall

      I've added the code I'm using for maze creation to the tests also.
      (defn random-maze-builder
      [size]
      (let [maze-size (+ size (* size size))
      break-idx (+ size 1)]
      (str
      (reduce
      (fn [maze idx]
      (let [next (cond
      (= idx 1) "."
      (= (mod idx break-idx) 0) "\n"
      (= idx (- maze-size 1)) "."
      :else (if (= 0 (rand-int 3))
      "W"
      "."))]
      (.append maze next)))
      (StringBuilder. maze-size)
      (range 1 maze-size)))))

    • Custom User Avatar
      • Unnamed
      • commented on ""Path Finder #1: can you reach the exit?" Clojure Translation"
      • 6 years ago

      random string creation is very time consuming in clojure

      If anything is very time consuming, it probably means it's done in the wrong way.
      Anyway, there should be some kind of random tests, maybe slightly randomized pre-generated strings or something else dynamically random.

    • Custom User Avatar
      • gargamel
      • commented on ""Smallest possible sum " Clojure Translation"
      • 6 years ago

      Wow I wasn't aware it would be twice as fast with mapv!
      Thanks, this is a tip to remember.

    • Custom User Avatar
      • Unnamed
      • commented on ""Smallest possible sum " Clojure Translation"
      • 6 years ago

      Too close to the maximum execution time. This solution randomly times out sometimes. Maybe change map to mapv in the tests? It makes a noticeable difference in performance.

    • Custom User Avatar
      • gargamel
      • commented on ""Sum of Intervals" Clojure Translation"
      • 6 years ago

      Fixed the comparator, unless I'm missing something additional (in case I'd appriciate you'd point out)

    • Custom User Avatar
      • Unnamed
      • commented on ""Sum of Intervals" Clojure Translation"
      • 6 years ago

      Print the result of sorting a random sequence to see, for example [[-410 211] [197 266] [195 400] [449 476] [491 496] [100 142] [213 379] [282 380] [12 302] [-296 172] [-7 149] [-23 120] [370 376] [-373 -339] [-302 -264] [226 289] [499 500] [-180 -130] [490 498] [234 424]].

    • Custom User Avatar
      • gargamel
      • commented on ""Sum of Intervals" Clojure Translation"
      • 6 years ago

      Could you please elaborate? When I tested it, it worked fine

    • Custom User Avatar
      • Unnamed
      • commented on ""Sum of Intervals" Clojure Translation"
      • 6 years ago

      Your comparator doesn't implement java.util.Comparator correctly, so the random tests expect incorrect results.

    • Custom User Avatar
      • gargamel
      • commented on "Scramblies" clojure solution
      • 6 years ago

      Having the frequencies call within the every makes it an O(n^2), so it's probably better to calculate them ahead of time

    • Custom User Avatar
      • gargamel
      • commented on "Find the odd int" cpp solution
      • 6 years ago

      Saying what's the issue with this solution would be much more helpful than just saying "is terrible"

    • Custom User Avatar
      • gargamel
      • commented on "Complementary DNA" cpp solution
      • 6 years ago

      Original signature is "std::string DNAStrand(const std::string& dna)" in which you can't change dna because of the "const"

    • Custom User Avatar
      • gargamel
      • commented on "Which are in?" clojure solution
      • 6 years ago

      You should probably "dedupe" only after the sort, as there is no promise array1 is sorted

    • Loading more items...
    • © 2025 Codewars
    • About
    • API
    • Blog
    • Privacy
    • Terms
    • Code of Conduct
    • Contact

    Confirm

    • Cancel
    • Confirm

    Collect: undefined

    Loading collection data...