# Count All Paths from Top left to bottom right in Two Dimensional Array including Diagonal Paths

```APPROACH:
Basically the approach is to count all paths for each cell.

CODE:
public class PrintAllPossiblePaths {
int rowCount;
int colCount;

public PrintAllPossiblePaths(int[][] arr) {
// TODO Auto-generated constructor stub
this.rowCount = arr.length;
this.colCount=arr[0].length;
}

private int countAllPaths(int rowNumber,int columnNumber){
if(rowNumber == 0 || columnNumber==0){
return 1;
}
else{
return countAllPaths(rowNumber,columnNumber-1) + countAllPaths(rowNumber-1,columnNumber-1) + countAllPaths(rowNumber-1,columnNumber);
}
}

private void printResultArray(int[][] a){
int[][] resultCountArray = new int[rowCount][colCount];
for(int i=0;i<rowCount;i++){
resultCountArray[i][0]= 1;
}

for(int j=0;j<colCount;j++){
resultCountArray[0][j]= 1;
}

for(int i=1;i<rowCount;i++){
for(int j=1;j<colCount;j++){
resultCountArray[i][j]= countAllPaths(i,j);
}
}

System.out.println("TOTAL POSSIBLE PATHS FOR EACH CELL:");
for(int i=0;i<rowCount;i++){
for(int j=0;j<colCount;j++){
System.out.print(" "+resultCountArray[i][j]);
}
System.out.println("");
}
System.out.println("TOTAL POSSIBLE PATHS: " + resultCountArray[rowCount-1][colCount-1]);
}

public static void main(String[] args) {
// TODO Auto-generated method stub
int[][] a = { { 1, 2, 3 ,4}, { 4, 5, 6 ,7}, { 7, 8, 9 ,10} };
PrintAllPossiblePaths p = new PrintAllPossiblePaths(a);
p.printResultArray(a);
}
}```

OUTPUT:

TOTAL POSSIBLE PATHS FOR EACH CELL:

1  1  1  1

1  3  5  7

1  5  13  25

TOTAL POSSIBLE PATHS: 25

# Buy XRP & Sleep Well At Night

I’m sure you’ve seen it yourself already, if you’ve entered crypto:

This person is iconic – a crypto trader that moves his money on a whim, hoping to catch a quick ride upwards from recent news, social media updates, or other rumors.  They are not serene individuals, and it’s apparent that the stress of following a market that never closes has taken its toll.

And I’m talking about individuals that do this full-time: What about the ordinary stock investor that has a regular 9-5 job?  Are they supposed to set aside their regular career just to follow crypto movements?

No.  To manage the stress of being “in crypto” while also pursuing their normal career, new investors will need to choose investments that allow them to continue with their normal life without being distracted by the temporary gyrations within the crypto industry.  I was one of those individuals…

View original post 3,428 more words

# Do you want to Retire Early in India? A detailed guide with Excel calculator

a must read for today’s generation

On the occasion of Dhanteras I’m re-posting my article from JagoInvestor. I’ll start writing regularly starting this Diwali month on the topics some of you wanted me to elaborate 🙂

• How I discovered Early Retirement?
• WHAT IS EARLY RETIREMENT?
• My Alternative Early Retirement Plan for Indian conditions
• The benefits of this alternative approach
• FREEDOM: Free by Age 40 to do work you truly enjoy
• SECURITY: Your retirement fund is actually a 25-year emergency fund!
• LESS STRESS: Not having to worry about money running out
• PRACTICE: Great Training for “full retirement”
• 4 STRATEGIES TO INCREASE YOUR SAVINGS RATE
• FAQ 1: If I’m saving first for my retirement what about saving for my child’s college expenses?
• FAQ 3: But we want to do extended travel frequently. That’s why we want to retire early and stop working!

View original post 4,194 more words

# URL shortening in Django with bit.ly

Building an application which has features to invite people or maybe share some data through those “big” “lengthy” URL is a disgrace for a developer and is a things of past.

In python along with bit.ly,believe me it becomes lot much easy although I had to struggle to write the most crisp peace of code which code serve the purpose.

Following are the steps :

1.) Signup with bit.ly and navigate to http://dev.bitly.com/

3.) Use following code snippet in your code to generate the shortened bit.ly in your code:

``````import urllib
import urllib2
import json

values = {'access_token' : BITLY_ACCESS_TOKEN,
url = "https://api-ssl.bitly.com/v3/shorten"

data = urllib.urlencode(values)
req = urllib2.Request(url,data)
print bitly_url``````

You don’t need to create a whole new app in your  Django project just for shortening the URL.

But if you want the all the features of the bit.ly API, start by reading the documentation at dev.bitly.com/get_started.html, and then download the official python client.

# Louis Van Gaal tactical philosophy

Have not read an article like this in ages…….complete logical maths involved and sheer brilliance of a visionist
People might call him arrogant but he is confident….
‪#‎GGMU‬

‘The national coach (me) sees opportunities because he believes in vision and structure. When I say that, I mean MY vision, and my structure. Yes, that is arrogant. I bet you hear that more, that people find me arrogant. It does not bother me.  I am NOT arrogant. But I do believe in my vision. So the people who work in my organization have something to hold on to. That is what I believe in.’

Football dominance comes in cycles, and although the inability to keep hold of key players disrupted the progress and dominance Van Gaal was on the verge of achieving in Amsterdam, his Ajax team are widely regarded as one of the greatest teams to have played the game.

“Ajax are not just the team of the Nineties, they are approaching football Utopia. Their concept of the game is exquisite yet they have a physical superiority as…

View original post 1,736 more words

# String vs StringBuffer in JAVA

SITUATION:In this present world,the performance of any application is very important and it’s then only when factors like RUNNING TIME and MEMORY occupied plays very critical role in deciding that factor.While working on one such deliverable i too came accross such condition where i need to read some million odd files and each containing some million odd records and do some operation on the data and overwrite or make a copy of the updated info and show to the user so i used STRINGS approach as any nooby will use and what i came accross was that it was taking almost like an hour to do it so i just being guided by seniors to use StringBuffer class instead of String.When i ran it after making the required changes it took only like 3-4 seconds which was like a miracle.Now that really makes a lot of difference and made me to get the details why did it happen and stuff and share it with everyone.

MECHANISM: So the reason why it happened was that String object is immutable whereas StringBuffer/StringBuilder objects are mutable.So what it means is that whenever u create any string object and assign any value on it and do any operation on it and try to update it,what it does is create a new String object and assign the updated value and doesnt assign it the previous one.So what was happening that for every file and every updation an object was being created in background so in all 1,000,000*1,000,000 many objects were created which was causing that much time to do whole process whereas what happens in StringBuffer is when u do any operation on an object then it will upadate it then and there only without taking any time

Finally, whats the difference between StringBuffer and StringBuilder?

StringBuffer and StringBuilder have the same methods with one difference and that’s of synchronization. StringBuffer is synchronized( which means it is thread safe and hence you can use it when you implement threads for your methods) whereas StringBuilder is not synchronized( which implies it isn’t thread safe).

So, if you aren’t going to use threading then use the StringBuilder class as it’ll be more efficient than StringBuffer due to the absence ofsynchronization.

# TimeStamp

While working in college we dnt get much chance to deal with all the datatypes in sql or some of the importatnt ones which you get it corporate world while working on some projects.One such is TIMESTAMP which is really different from the normal DATE datatype and its format is like yyyy/MM/dd hh24:mi:ss.SSSSSS.

PROBLEM:  So the problem now is how to deal with this format coz it always use to give errors like: Error: ORA-01830: date format picture ends before converting entire input string or ORA-01843 “not a valid month” and ORA-01861 “literal does not match format string” .So the problem occur due to the SSSSSS part in the end.

SOLUTION: So i came accross many solutions on net of which the few are:

1.instead of using to_date and use `to_timestamp('2010-12-14:09:56:53', 'YYYY-MM-DD:HH24:MI:SS')`

2.to_date(?,’DD/MM/YYYY HH24:MI:SS’) -in place of ? just put the new entry that you want to insert.

and similarly like this many more but no one was of use so that encouraged me to share the solution with you.

The best way to is to take the substring of the new entry from 0 to indexof(.) so what you get is  yyyy/MM/dd HH24:MI:ss and just put it place and the compiler will take care of the rest .Hope it will be beneficial for you and you dont have to scroll through thousands of web pages and still unable to get the right solution to the problem.