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

Week 1 #1

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Week 1 #1

wants to merge 6 commits into from

Conversation

danpersa
Copy link

No description provided.

(facts "should return the odd numbers"
(odd-numbers #{1 2 3 4 5}) => '(1 3 5))

(defn palindrome [col]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, a simpler solution exists, it's enough to compare the original sequence to its reversed version

(loop [result 1
index 1]
(if (= index n)
(* result index)
Copy link
Owner

@dryewo dryewo May 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not optimal: you have * in two places. Try running index from n down to 1.
Also, try running it with big numbers - it causes integer overflow. Use *' instead of *

@dryewo dryewo self-assigned this May 9, 2016
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