Re: Optimizing code : Fun but now paining me

2014-10-17 Thread Ashish Negi
Places where drop is being used : 1. https://gist.github.com/ashishnegi/ef3c65182c09c154126b#file-shunting-algo-clj-L218 2. https://gist.github.com/ashishnegi/ef3c65182c09c154126b#file-shunting-algo-clj-L250 drop-while at more locations in code. On furthur thinking it looks like if they ret

Re: Optimizing code : Fun but now paining me

2014-10-17 Thread Ashish Negi
Thanks @Gunnar and @barnardH For this time i have been asking you to look at code and find performance points which is not that good way. so i think i better start asking specific questions how dump it may sound : [ i m a newbie ] I hope that normal things that i know about list and vectors hol

Re: Optimizing code : Fun but now paining me

2014-10-17 Thread Gunnar Völkel
I spot the following problems in your code with respect to primitive functions: 1. You declare functions (ModAdd, ...) with primitive arguments but without primitive return values. So you get boxing on the return values. 2. You pass those primtive functions as argument to EulerPowNonMemoized,

Re: Optimizing code : Fun but now paining me

2014-10-17 Thread bernardH
On Friday, October 17, 2014 12:51:01 PM UTC+2, Ashish Negi wrote: > > Ok so i am back with this and rechanged the code and used another > algorithm : created by great Dijkstra Shunting Yard algo which creates the > infix to postfix conversion. > > My implementation here : > https://gist.github

Re: Optimizing code : Fun but now paining me

2014-10-17 Thread Ashish Negi
Ok so i am back with this and rechanged the code and used another algorithm : created by great Dijkstra Shunting Yard algo which creates the infix to postfix conversion. My implementation here : https://gist.github.com/ashishnegi/ef3c65182c09c154126b Now, i have only one test case unsolved whi

Re: Optimizing code : Fun but now paining me

2014-10-15 Thread Ashish Negi
Problem is to evaluate a calculator string containing * / + - and brackets like "2+3*(4+2)/2/2" and the grammar for this is right associative for operators and precendence is as we know : ->unaray, brackets >*/>+- Also answer should be in (mod 17) which require

Re: Optimizing code : Fun but now paining me

2014-10-15 Thread Baishampayan Ghose
Can you still tell me what the problem statement is? I saw some mutation in the earlier code, may be it was for testing. ~BG On Tue, Oct 14, 2014 at 6:25 PM, Ashish Negi wrote: > @BG > > Glad to know i am interacting with you :) > Of course i understand that you are not criticizing me.. > > I hav

Re: Optimizing code : Fun but now paining me

2014-10-14 Thread Ashish Negi
@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) mo

Re: Optimizing code : Fun but now paining me

2014-10-14 Thread Anil wadghule
Guys, you could use http://gist.github.com to share long code snippets. That way code can have good Clojure syntax highlighting and be readable.  --  Anil — Sent from Mailbox On Wed, Oct 15, 2014 at 5:32 AM, bernardH wrote: > Sorry but I don't feel that I'm understanding your code enough t

Re: Optimizing code : Fun but now paining me

2014-10-14 Thread bernardH
Sorry but I don't feel that I'm understanding your code enough to rewrite it (for instance, why substract 2 at https://gist.github.com/ashishnegi/a9ae3fb3c270c7d3742e#file-calculator-clj-L102 to add 2 at https://gist.github.com/ashishnegi/a9ae3fb3c270c7d3742e#file-calculator-clj-L16 ?). But i

Re: Optimizing code : Fun but now paining me

2014-10-14 Thread Ashish Negi
@BG Glad to know i am interacting with you :) Of course i understand that you are not criticizing me.. I have refactored my code and have made a gist.. that may help.. I have put some comments. https://gist.github.com/ashishnegi/a9ae3fb3c270c7d3742e please share your comments on that. I am reall

Re: Optimizing code : Fun but now paining me

2014-10-14 Thread Baishampayan Ghose
The size of the code doesn't matter, I have read much larger code-bases in less than 10 mins. Your code is unreadable because of weird naming of locals, completely absurd indentation, use of mutation, etc. It's just too much work to interpret the code. I think it will be better if you share the p

Re: Optimizing code : Fun but now paining me

2014-10-14 Thread Ashish Negi
Also just for the record.. My first post had Main code and the code that i used it for testing separated by a line saying * Test *** there I am concerned about the Main code and testing code is there if somebody wants to just put every thing in repl and try few

Re: Optimizing code : Fun but now paining me

2014-10-14 Thread Ashish Negi
@Baishampayan Ghose You caught me right.. i am a novice in clojure.. But most of my functions are smaller ( upto problem requirement ) and self containing.. so i think that you might be having issues with some particular function.. If that is so.. i can put some comments and refactor that part

Re: Optimizing code : Fun but now paining me

2014-10-13 Thread Baishampayan Ghose
No offence, Ashish, but this code is unreadable, this is horrible. It'll be better if you first learn Clojure before you look for optimizations. ~BG On Mon, Oct 13, 2014 at 6:40 PM, Ashish Negi wrote: > I am competing in an online competition and the scenario is like this : > I coded with my basi

Re: Optimizing code : Fun but now paining me

2014-10-13 Thread Ashish Negi
Thanks juan I thought that people would prefer the code.. and just wanted to have them glanced at it.. and tell if i am missing something basic. But here is a little list of things i tried : The problem is that of evaluation calculator expressions containig *,/,+,- and (, ) and the grammar for

Re: Optimizing code : Fun but now paining me

2014-10-13 Thread juan.facorro
That is a whole lot of code to check and test for optimizations :P How are you identifying the problems in your code that need optimization? Are you doing some kind of profiling or just trying stuff out? If you are not doing it already, I would recommend using VisualVM [1] to get a clearer pict

Re: Optimizing code : Fun but now paining me

2014-10-13 Thread Ashish Negi
It would be great if you people can help me with the optimization and it may work.. or can just guide me towards resources.. :) Thanks -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Not

Re: Optimizing code : Fun but now paining me

2014-10-13 Thread Ashish Negi
It would be great if you people could help me with the optimization .. just few tricks and it may work.. or guide me towards the resources.. On Monday, 13 October 2014 18:40:15 UTC+5:30, Ashish Negi wrote: > > I am competing in an online competition and the scenario is like this : > I coded with

Optimizing code : Fun but now paining me

2014-10-13 Thread Ashish Negi
I am competing in an online competition and the scenario is like this : I coded with my basic knowledge of clojure and got 11 out of 20 testcases and others being timed out and one being runtime error.. I started optimizing my code and read https://groups.google.com/forum/#!searchin/clojure/perf