Skip to content

homework-02-ataranchiev#4

Open
ewok wants to merge 4 commits into
Clojure-Developer:mainfrom
ewok:homework-02
Open

homework-02-ataranchiev#4
ewok wants to merge 4 commits into
Clojure-Developer:mainfrom
ewok:homework-02

Conversation

@ewok
Copy link
Copy Markdown

@ewok ewok commented Jul 7, 2024

No description provided.

Copy link
Copy Markdown

@Ivana- Ivana- left a 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! :)

Comment thread otus-02/src/otus_02/homework/palindrome.clj Outdated
Comment thread otus-02/src/otus_02/homework/palindrome.clj Outdated
Comment thread otus-02/src/otus_02/homework/palindrome.clj Outdated
Comment thread otus-02/src/otus_02/homework/palindrome.clj Outdated
Comment thread otus-02/src/otus_02/homework/palindrome.clj Outdated
Comment thread otus-02/src/otus_02/homework/palindrome.clj Outdated
Comment thread otus-02/src/otus_02/homework/palindrome.clj Outdated
Comment thread otus-02/src/otus_02/homework/pangram.clj
Comment thread otus-02/src/otus_02/homework/pangram.clj Outdated
@ewok ewok changed the title homework-02 - p1 homework-02 - ataranchiev Jul 11, 2024
@ewok ewok changed the title homework-02 - ataranchiev homework-02-ataranchiev Jul 12, 2024
Copy link
Copy Markdown

@Ivana- Ivana- left a 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))))))

Copy link
Copy Markdown

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]
Copy link
Copy Markdown

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?
Copy link
Copy Markdown

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))))
Copy link
Copy Markdown

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"
Copy link
Copy Markdown

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?)
Copy link
Copy Markdown

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))
Copy link
Copy Markdown

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))))
Copy link
Copy Markdown

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)
Copy link
Copy Markdown

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))))))))
Copy link
Copy Markdown

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! )

Copy link
Copy Markdown
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants