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

41/46 #32

Open
AlexanderChenNL opened this issue Jan 3, 2018 · 3 comments
Open

41/46 #32

AlexanderChenNL opened this issue Jan 3, 2018 · 3 comments

Comments

@AlexanderChenNL
Copy link

Hi there,

I want to start this one but what do i do with the following:
[0 1 2 3 4 5 6 7 8 9]
These are single digits so how the 15 split into 1 and 5 or 10 split into 1 and 0 don't really apply. What is the usecase then?

@ertugrulcetin
Copy link
Member

I think the explanation is clear:

Write a function called square-dig which takes a collection of integers as an argument. Return the count of how many elements are smaller than the sum of their squared component digits. For example: 10 is larger than 1 squared plus 0 squared; whereas 15 is smaller than 1 squared plus 5 squared.

@ertugrulcetin
Copy link
Member

Hi @AlexanderChenNL are you able to solve the problem? if not here is the solution:

(defn square-dig [coll]
                 (let [sumOfSquaredComponent (->> coll
                                                  (map str)
                                                  (map seq)
                                                  (map #(map (fn [x] (- (int x) 48)) %))
                                                  (map #(map (fn [x] (* x x)) %))
                                                  (map #(reduce + %)))]
                   (count (filter true? (map > sumOfSquaredComponent coll)))))

@AlexanderChenNL
Copy link
Author

HI Ertugrul,

No I was not able to solve it because i did not understand the question. I have switched over to 4clojure.com website because as a beginner in
clojure i lear a lot from the solutions of others. I will get back to where I am in clojureacademy once i have gained more understanding.

best,

Alexander Chen

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

No branches or pull requests

2 participants