public class sqq {
String X,Y;
int blankfine=10,matchfine = 100;
int fine(char a, char b){
if(a==b)
return 0;
if(a=='-'||b=='-')
return blankfine;
return matchfine;
}
int seqAlign(int i, int j){
if(i==0&&j==0)
return fine(X.charAt(0),Y.charAt(0));
if(i<0&&j>=0)
return j*blankfine;
if(j<0&&i>=0)
return i*blankfine;
int t1 = seqAlign(i-1,j-1)+fine(X.charAt(i),Y.charAt(j));
int t2 = seqAlign(i-1,j)+fine(X.charAt(i),'-');
int t3 = seqAlign(i,j-1)+fine(Y.charAt(j),'-');
int temp = min(t1 , t2 , t3);
System.out.println("i= "+i+" j= "+j+" Ans: " + temp);
System.out.println(t1+" "+t2+" "+t3);
System.out.println("char i: "+X.charAt(i)+" char j: "+Y.charAt(j));
return temp;
}
int min(int a,int b, int c){
if(a<b&& a<c)
return a;
if(b<a&& b<c)
return b;
if(c<b&& c<a)
return c;
if(a<b)
return a;
else
return b;
}
public static void main(String farts[]){
sqq sq = new sqq();
sq.X = "ce";
sq.Y = "cd";
System.out.println(sq.seqAlign(sq.X.length()-1,sq.Y.length()-1));
}
}
A gateway to a software developer's regular attempts to live by choice and not chance while not abandoning the fun that chance brings.
Thursday, January 31, 2013
Sequence Alignment problem: Recursive solution without memoization
Tuesday, January 29, 2013
MOOCs and me
MOOC is an acronym for Massive Open Online Course and these have spread open knowledge in the last one year in an amazing way. Every person has his own view on courses and would like to take his own time, references and relate to the subject in a way most convenient for him. MOOCs make a platform where this is feasible.
To me MOOCs have been the biggest gamechanger since 2011. I like learning new things, but I am not the fastest of learners. I take my time, I read and I re-read. And MOOCs let me take my time, giving me a chance to change, a change to improve and a change to achieve.
For the uninitiated, I believe the first set of popular online MOOCs were ai-class.com, db-class.com and ml-class.com. After doing two of the three(Could not do DB), I realized how much they actually helped me widen my thinking. I wanted to do more courses, learn more. But seeing the lectures was hardly the main part. It was all about the assignments and the quizzes. They are the main ingredient specially for students who understand mainly by doing.
This was followed by a plethora of online courses which are now so many that it is barely possible to keep a count. I will however mention the two primary sites that keep me on my toes:
coursera.org
udacity.com
Also, please visit http://www.class-central.com/ which provides an updated list to all the courses from (perhaps) all the sites.
Thanks you all Professors, courses, and other people involved in making online education a success and kudos for keeping it free and helping me in life.
Got this graphic from OnlineCollegeCoursesTo me MOOCs have been the biggest gamechanger since 2011. I like learning new things, but I am not the fastest of learners. I take my time, I read and I re-read. And MOOCs let me take my time, giving me a chance to change, a change to improve and a change to achieve.
For the uninitiated, I believe the first set of popular online MOOCs were ai-class.com, db-class.com and ml-class.com. After doing two of the three(Could not do DB), I realized how much they actually helped me widen my thinking. I wanted to do more courses, learn more. But seeing the lectures was hardly the main part. It was all about the assignments and the quizzes. They are the main ingredient specially for students who understand mainly by doing.
This was followed by a plethora of online courses which are now so many that it is barely possible to keep a count. I will however mention the two primary sites that keep me on my toes:
coursera.org
udacity.com
Also, please visit http://www.class-central.com/ which provides an updated list to all the courses from (perhaps) all the sites.
Thanks you all Professors, courses, and other people involved in making online education a success and kudos for keeping it free and helping me in life.
Thursday, December 27, 2012
Using JSON with Jmeter
Thanks to Deepak and his post here, I could get JSON working with Jmeter which was essential for testing when the payload was a json object when sending and receiving.
For the lazier people who might not visit the link, just download the json reference implementation code, compile and make a jar and put it in the lib directory of jmeter.
Another thing, keep looking at the code in the JSON implementations for the correct signatures when writing stuff.
Good luck!
For the lazier people who might not visit the link, just download the json reference implementation code, compile and make a jar and put it in the lib directory of jmeter.
Another thing, keep looking at the code in the JSON implementations for the correct signatures when writing stuff.
Good luck!
Subscribe to:
Posts (Atom)