Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

ewok
Copy link

@ewok ewok commented Jul 7, 2024

No description provided.

Copy link

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

otus-02/src/otus_02/homework/palindrome.clj Outdated Show resolved Hide resolved
otus-02/src/otus_02/homework/palindrome.clj Outdated Show resolved Hide resolved
otus-02/src/otus_02/homework/palindrome.clj Outdated Show resolved Hide resolved
otus-02/src/otus_02/homework/palindrome.clj Outdated Show resolved Hide resolved
otus-02/src/otus_02/homework/palindrome.clj Outdated Show resolved Hide resolved
otus-02/src/otus_02/homework/palindrome.clj Outdated Show resolved Hide resolved
otus-02/src/otus_02/homework/palindrome.clj Outdated Show resolved Hide resolved
otus-02/src/otus_02/homework/pangram.clj Show resolved Hide resolved
otus-02/src/otus_02/homework/pangram.clj Outdated Show resolved Hide resolved
@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

@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

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

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

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

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

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

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

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

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

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

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