-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
homework-02-ataranchiev #4
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job! Good luck with rest of the task! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good, there are some minor issues, but you made a good recearch & work, I see your progress! We'll discuss important points on Q&A stream
all-children)] | ||
((fnil #(apply max %) [0]) | ||
(seq (map count (intersection filtered-f filtered-s)))))) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overcomplexed unoptimal and actually wrong solution )
|
||
;; Using recursion | ||
(defn common-child-length | ||
[^String f ^String s] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, that's the goal!
(->> s | ||
string/lower-case | ||
vec | ||
(filterv is-alpha?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know it at that point. Decided to leave it as it is.
No description provided.