Conversation
Ivana-
left a comment
There was a problem hiding this comment.
Good job! Good luck with rest of the task! :)
| all-children)] | ||
| ((fnil #(apply max %) [0]) | ||
| (seq (map count (intersection filtered-f filtered-s)))))) | ||
|
|
There was a problem hiding this comment.
Overcomplexed unoptimal and actually wrong solution )
|
|
||
| ;; Using recursion | ||
| (defn common-child-length | ||
| [^String f ^String s] |
There was a problem hiding this comment.
Gooooooood point for interop, we'll discuss it at Q&A stream
| (ns otus-02.homework.lib | ||
| (:require [clojure.string :as string])) | ||
|
|
||
| (defn- is-alpha? |
There was a problem hiding this comment.
There is Character/isAlphaOrNumeric and other Java static methods
| (empty? rest-string) false | ||
| :else (recur (difference rest-alpha | ||
| (set (string/lower-case (first | ||
| rest-string)))) |
There was a problem hiding this comment.
A man with the hammer looks at everything as on the nail ))
Just (disj my-set my-element)
| ;; With Lorem ipsum | ||
| ; (out) "Elapsed time: 391.425171 msecs" | ||
| ; (out) "Elapsed time: 475.359696 msecs" | ||
| ; (out) "Elapsed time: 59.689839 msecs" |
| (->> s | ||
| string/lower-case | ||
| vec | ||
| (filterv is-alpha?) |
There was a problem hiding this comment.
Once you call apply str, then you don't need force all in memory as vector, just lazy filter
| input-size (count normalized-input) | ||
| [columns rows] (get-dimensions input-size)] | ||
| (->> (concat normalized-input | ||
| (repeat (- (* columns rows) input-size) \space)) |
There was a problem hiding this comment.
(format (str "%-" (* rows cols) "s")) :)
| (repeat (- (* columns rows) input-size) \space)) | ||
| (partition columns) | ||
| (apply map str) | ||
| (string/join \space)))) |
There was a problem hiding this comment.
Except concat, excellent idiomatic & effective solution!
| [_ rows] (get-dimensions input-size)] | ||
| (->> (str input \space) | ||
| (partition (inc rows)) | ||
| (map butlast) |
There was a problem hiding this comment.
butlast is not effective on lists, but ok, it works
| "Eva, can I see bees in a cave?" "Was it a cat I saw?"]] | ||
| (is (f s))) | ||
| (doseq [s ["civics" "They all have one thing" "knock on the door"]] | ||
| (is (not (f s)))))))) |
There was a problem hiding this comment.
You do know .charAt, I saw it above! )) Why don't use it in this task?! The fastest way without ANY extra memory usage! )
There was a problem hiding this comment.
I didn't know it at that point. Decided to leave it as it is.
No description provided.