@bernardH
Thanks bernardH for your help.
1. Why subtract 2 ?
It is an euler theoram : for finding Modulo inverse , I have written
the formula in comments just above the line. ToMod is a big prime number.
Euler says for (a/b) mod P where P is big prime number == (a * (b ^
(P-2))mod P) mod P
That is why 2 comes there.
2. EulerDivNonMemoized takes x and p and calculates x ^ p ; it assumes that
p+2 is going to be a Prime number > x
3. I am taking part in programming contest and their enviroment at
https://www.hackerrank.com/environment i would not have access to these
libraries.
4. The whole problem is of creating abstract syntax tree .. I am creating
it recursively. After AST , problem would be sufficiently simpler.
5. As a design rule you are right about make-calculator-list returning
tokens rather than strings.. but does that really cost me in computation ?
because i would have to do that work sooner or later..
6. I think you are right about using long rather than int. But i am not
getting wrong answers but timeout problems .. but i would definitely do
this change.
7. Thinking non recursively makes it difficult. I mean grammar was
recursive so it was much easier to code it in recursive nature. But
definitely recursion is going to do StackOverflow at larger inputs. You are
right about that.
Q. Are seq passing across functions can be a bottleneck ? i mean it would
only the reference of seqs that would have been passed around because
everything is immutable.
@Anil I have shared the code here :
https://gist.github.com/ashishnegi/a9ae3fb3c270c7d3742e#file-calculator-clj
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.